tvalentyn commented on code in PR #21868:
URL: https://github.com/apache/beam/pull/21868#discussion_r898053104


##########
sdks/python/apache_beam/ml/inference/pytorch_inference.py:
##########
@@ -99,6 +102,9 @@ def run_inference(
 
     This method stacks the list of Tensors in a vectorized format to optimize
     the inference call.
+
+    Returns:
+      An Iterable of type PredictionResult.

Review Comment:
   we can also add a docstring for PredictionResult, for example, by assigning 
it to 
   ```
   PredictionResult.__doc__ = """\
   ...  
   """
   ```



##########
sdks/python/apache_beam/ml/inference/pytorch_inference.py:
##########
@@ -55,21 +55,24 @@ def _convert_to_device(examples: torch.Tensor, device) -> 
torch.Tensor:
 class PytorchModelHandlerTensor(ModelHandler[torch.Tensor,
                                              PredictionResult,
                                              torch.nn.Module]):
-  """ Implementation of the ModelHandler interface for PyTorch."""
   def __init__(
       self,
       state_dict_path: str,
       model_class: Callable[..., torch.nn.Module],
       model_params: Dict[str, Any],
       device: str = 'CPU'):
-    """
-    Initializes a PytorchModelHandlerTensor
-    :param state_dict_path: path to the saved dictionary of the model state.
-    :param model_class: class of the Pytorch model that defines the model
-    structure.
-    :param device: the device on which you wish to run the model. If
-    ``device = GPU`` then a GPU device will be used if it is available.
-    Otherwise, it will be CPU.
+    """Implementation of the ModelHandler interface for PyTorch.
+
+    Example Usage:
+      pcol | RunInference(PytorchModelHandlerTensor(state_dict_path="my_uri"))

Review Comment:
   (optional nit): I think `pcoll` is more common in our docs.



-- 
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]

Reply via email to