对于满足broadcast关系的两个shape,推导他们broadcast后的shape。例如[1, 10]与[2, 1] broadcast后的shape为[2, 10]。
bool BroadcastInferShape(const Shape &self, const Shape &other, shape &broadcastShape)
参数 |
输入/输出 |
说明 |
---|---|---|
self |
输入 |
第一组shape。 |
other |
输入 |
第二组shape。 |
broadcastShape |
输出 |
self和other经过broadcast后推导的shape。 |
当self与other满足broadcast关系时,返回true,否则返回false。
无
1 2 3 4 5 6 7 8 9 10 11 | // 生成shape为[2, 1]和[2, 10]的两个Shape对象,获取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); } |