robertwb commented on code in PR #17470:
URL: https://github.com/apache/beam/pull/17470#discussion_r871834743
##########
sdks/python/apache_beam/ml/inference/pytorch.py:
##########
@@ -45,11 +46,22 @@ def run_inference(self, batch: List[torch.Tensor],
This method stacks the list of Tensors in a vectorized format to optimize
the inference call.
"""
-
- batch = torch.stack(batch)
- if batch.device != self._device:
- batch = batch.to(self._device)
- predictions = model(batch)
+ if isinstance(batch[0], dict):
Review Comment:
+1. If PytorchInferenceRunner (and its associated ModelLoder) were typed, we
would have one that takes tensors and one that takes dicts of tensors, and this
typing would go all the way through to the PCollections being PCollections of
tensors vs. PCollections of dicts of tensors.
--
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]