You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/06/24 01:50:38 UTC

[GitHub] [tvm] masahi commented on a diff in pull request #11863: [Relay] [PyTorch] Add aten::broadcast_tensors

masahi commented on code in PR #11863:
URL: https://github.com/apache/tvm/pull/11863#discussion_r905654191


##########
python/tvm/relay/frontend/pytorch.py:
##########
@@ -1952,6 +1952,13 @@ def expand_as(self, inputs, input_types):
             target = _op.cast(target, t0)
         return _op.broadcast_to_like(inputs[0], target)
 
+    def broadcast_tensors(self, inputs, input_types):
+        tensor_list = inputs[0]
+        import torch
+
+        res_shape = list(torch.broadcast_shapes(*[self.infer_shape(t) for t in tensor_list]))
+        return [_op.broadcast_to(tensor, res_shape) for tensor in tensor_list]

Review Comment:
   oh interesting. Have you verified that this is what `broadcast_tensors` does? It's interesting that we are actually invoking pytorch function for conversion purpose.



-- 
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: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org