BroadcastInferShape
Function Usage
Infers the broadcast shape for two shapes. For [1, 10] and [2, 1], the broadcast shape is [2, 10].
Prototype
bool BroadcastInferShape(const Shape &self, const Shape &other, shape &broadcastShape)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
self |
Input |
Shape of the first group. |
other |
Input |
Shape of the second group. |
broadcastShape |
Output |
Broadcast shape for self and other. |
Returns
true: The broadcast relationship is met between the self and other parameters; false: otherwise.
Constraints
None
Example
1 2 3 4 5 6 7 8 9 10 11 | // Generate two shape objects with shapes [2, 1] and [2, 10] to obtain the broadcast shape. void Func() { gert::Shape shapeA; shapeA.AppendDim(1); shapeA.AppendDim(2); gert::Shape shapeB; shapeB.AppendDim(10); shapeB.AppendDim(2); gert::Shape shapeBrc; bool isBrc = BroadcastInferShape(shapeA, shapeB, shapeBrc); } |
Parent topic: shape_utils