rich7420 commented on code in PR #1106:
URL: https://github.com/apache/mahout/pull/1106#discussion_r2875654664
##########
qdp/qdp-python/qumat_qdp/loader.py:
##########
@@ -254,6 +343,25 @@ def _create_iterator(self) -> Iterator[object]:
)
)
+ def _wrap_iterator(self, raw_iter: Iterator[object]) -> Iterator[Any]:
+ if self._output_format is None:
+ yield from raw_iter
+ return
+ kind = self._output_format[0]
+ if kind == "torch":
+ device = self._output_format[1]
+ for qt in raw_iter:
+ t = _torch.from_dlpack(qt)
+ yield t.cpu() if device == "cpu" else t
+ elif kind == "numpy":
+ for qt in raw_iter:
+ yield _torch.from_dlpack(qt).cpu().numpy()
Review Comment:
oh , nice catch! you're right
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]