Category: Data movement
Short description: Broadcast replicates data on the first input to fit a given shape on the second input.
Broadcast takes the first tensor
data and, following broadcasting rules that are specified by
mode attribute and the 3rd input
axes_mapping, builds a new tensor with shape matching the 2nd input tensor
target_shape input is a 1D integer tensor that represents required shape of the output.
mode and the 3rd input
axes_mapping are relevant for cases when rank of the input
data tensor doesn't match the size of the
target_shape input. They both define how axes from
data shape are mapped to the output axes. If
mode is set to
numpy, it means that the standard one-directional numpy broadcasting rules are applied. They are similar to rules that applied in all binary element-wise operations in case when
auto_broadcasting attribute is set to
numpy, and are similar to rules described at here, when only one-directional broadcasting is applied: input tensor
data is broadcasted to
target_shape but not vice-versa.
In case if
mode is set to
explicit, then 3rd input
axes_mapping comes to play. It contains a list of axis indices, each index maps an axis from the 1st input tensor
data to axis in the output. The size of
axis_mapping should match the rank of input
data tensor, so all axes from
data tensor should be mapped to axes of the output.
axes_mapping =  enables broadcasting of a tensor with shape
[C] to shape
[N,C,H,W] by replication of initial tensor along dimensions 0, 2 and 3. Another example is broadcasting of tensor with shape
[H,W] to shape
axes_mapping = [1, 2]. Both examples requires
mode set to
explicit and providing mentioned
axes_mapping input, because such operations cannot be expressed with
axes_mapping set to
input tensor axes to output shape axes.
target_shape. If this attribute value is used, then the 3rd input for the operation shouldn't be provided.
data shape axes to output shape is provided as an explicit 3rd input.
data - source tensor of any type and shape that is being broadcasted. Required.
taget_shape - 1D integer tensor describing output shape. Required.
axes_mapping - 1D integer tensor describing a list of axis indices, each index maps an axis from the 1st input tensor
data to axis in the output. The index values in this tensor should be sorted, that disables on-the-fly transpositions of input
data tensor while the broadcasting.
axes_mapping input is optional depending on
data and with shape matched