oneflow.broadcast_tensors¶
-
oneflow.
broadcast_tensors
(*tensors) → List of Tensors¶ The interface is consistent with PyTorch. The documentation is referenced from: https://pytorch.org/docs/1.10/generated/torch.broadcast_tensors.html.
Broadcasts the given tensors according to
broadcasting-semantics
.- Parameters
*tensors – any number of tensors of the same type
Warning
More than one element of a broadcasted tensor may refer to a single memory location. As a result, in-place operations (especially ones that are vectorized) may result in incorrect behavior. If you need to write to the tensors, please clone them first.
Example:
>>> import oneflow as flow >>> x = flow.arange(3).view(1, 3) >>> y = flow.arange(2).view(2, 1) >>> a, b = flow.broadcast_tensors(x, y) >>> a.size() oneflow.Size([2, 3]) >>> a tensor([[0, 1, 2], [0, 1, 2]], dtype=oneflow.int64)