CheckBroadcastShape

Function Usage

Checks whether two shapes meet the broadcast relationship. For example, [2, 1] and [2, 10] meet the broadcast relationship, but [2, 2] and [2, 10] do not.

Prototype

bool CheckBroadcastShape(const Shape &self, const Shape &other)

Parameters

Parameter

Input/Output

Description

self

Input

Shape of the first group.

other

Input

Shape of the second group.

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
// Generate two shape objects whose shapes are [2, 1] and [2, 10], and check whether the two shapes meet the broadcast relationship.
void Func() {
    gert::Shape shapeA;
    shapeA.AppendDim(1);
    shapeA.AppendDim(2);
    gert::Shape shapeB;
    shapeB.AppendDim(10);
    shapeB.AppendDim(2);
    bool isBrc = CheckBroadcastShape(shapeA, shapeB);
}