Rate this Page

torch.broadcast_tensors#

torch.broadcast_tensors(*tensors)ListofTensors[source]#

Broadcasts the given tensors according toBroadcasting semantics.

Parameters

*tensors – any number of tensors of the same type

Warning

More than one element of a broadcasted tensor may refer to a singlememory location. As a result, in-place operations (especially ones thatare vectorized) may result in incorrect behavior. If you need to writeto the tensors, please clone them first.

Example:

>>>x=torch.arange(3).view(1,3)>>>y=torch.arange(2).view(2,1)>>>a,b=torch.broadcast_tensors(x,y)>>>a.size()torch.Size([2, 3])>>>atensor([[0, 1, 2],        [0, 1, 2]])