TheNeuralBit commented on code in PR #17470:
URL: https://github.com/apache/beam/pull/17470#discussion_r867282646
##########
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:
It might clean things up to only handle the general case and not have
special logic for the single-argument case.
--
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]