[
https://issues.apache.org/jira/browse/BEAM-13984?focusedWorklogId=753578&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-753578
]
ASF GitHub Bot logged work on BEAM-13984:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 06/Apr/22 18:31
Start Date: 06/Apr/22 18:31
Worklog Time Spent: 10m
Work Description: TheNeuralBit commented on code in PR #17196:
URL: https://github.com/apache/beam/pull/17196#discussion_r844264236
##########
sdks/python/apache_beam/ml/inference/pytorch_impl.py:
##########
@@ -0,0 +1,119 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# pytype: skip-file
+
+from typing import Iterable
+from typing import List
+from typing import Union
+
+import numpy as np
+import pickle
+import torch
+from torch import nn
+
+from apache_beam.ml.inference.base import InferenceRunner
+from apache_beam.ml.inference.base import ModelLoader
+
+
+class PytorchInferenceRunner(InferenceRunner):
+ """
+ Implements Pytorch inference method
+ """
+ def __init__(self, input_dim: int, device: torch.device):
+ self._input_dim = input_dim
+ self._device = device
+
+ def run_inference(
+ self, batch: List[Union[np.ndarray, torch.Tensor]],
Review Comment:
Shouldn't our Beam abstraction be opinionated about the element type instead
of using the native type for each library? Otherwise I'd argue this is just a
library of similar-looking extensions for different ML libraries
Issue Time Tracking
-------------------
Worklog Id: (was: 753578)
Time Spent: 1h 10m (was: 1h)
> Implement RunInference for PyTorch
> ----------------------------------
>
> Key: BEAM-13984
> URL: https://issues.apache.org/jira/browse/BEAM-13984
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Andy Ye
> Assignee: Andy Ye
> Priority: P2
> Labels: run-inference
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> Implement RunInference for PyTorch as described in the design doc
> [https://s.apache.org/inference-sklearn-pytorch]
> There will be a pytorch_impl.py file that contains PyTorchModelLoader and
> PyTorchInferenceRunner classes.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)