@@ -49,34 +49,36 @@ def Shape_AddOp : Shape_Op<"add", [Commutative, NoSideEffect]> {
49
49
def Shape_BroadcastOp : Shape_Op<"broadcast", [Commutative]> {
50
50
let summary = "Returns the broadcasted output shape of two inputs";
51
51
let description = [{
52
- Computes the broadcasted output shape following:
53
- 1. If any inputs are unranked, output is unranked;
54
- 2. Else the input array with number of dimensions smaller than the max
55
- input dimension, has 1’s prepended to its shapes and the output shape is
56
- calculated as follows:
57
-
58
- output[i] = lhs[i] if lhs[i] == rhs[i] or rhs[i] is unknown/undefined
59
- = rhs[i] if lhs[i] is unknown/undefined
60
- = lhs[i] if rhs[i] == 1
61
- = rhs[i] if lhs[i] == 1
62
- = error if lhs[i] != rhs[i]
63
-
64
- Op has an optional string attribute for the error case where there is no
65
- broadcastable output shape possible for the given inputs.
66
-
67
- Op may also return an ExtentTensor, but this should only be done when this
68
- is statically guaranteed to never fail, either because of a dependency on a
69
- cstr_broadcastable operation or other details of the construction of the
70
- program.
52
+ Returns the broadcasted shape for two input shapes or extent tensors. Both
53
+ operands can be of type `shape.shape` or `tensor<?xindex>`. The result is of
54
+ type `shape.shape` and, if both operands are tensors, may be of type
55
+ `tensor<?xindex>`.
56
+
57
+ If the two operand shapes are of different rank the smaller one is padded
58
+ with 1's from the left. The resulting broadcasted shape is then defined as
59
+
60
+ result[i] = lhs[i] if lhs[i] == rhs[i]
61
+ = lhs[i] if rhs[i] == 1
62
+ = rhs[i] if lhs[i] == 1.
63
+
64
+ In case the resulting shape is undefined, i.e. if corresponding extents are
65
+ different from each other but none is 1, the result is an error shape.
66
+ Likewise error values are propagated if any of the operands holds an error
67
+ value. If the result type is an extent tensor (and can therefore not hold
68
+ the error value) the behavior may be undefined. The optional string
69
+ attribute can be used to describe the error case.
71
70
}];
72
71
73
72
let arguments = (ins Shape_ShapeOrExtentTensorType:$lhs,
74
73
Shape_ShapeOrExtentTensorType:$rhs,
75
74
OptionalAttr<StrAttr>:$error);
76
75
let results = (outs Shape_ShapeOrExtentTensorType:$result);
77
76
78
- let assemblyFormat = "$lhs `,` $rhs attr-dict `:` type($lhs) `,` type($rhs) `->` type($result)";
77
+ let assemblyFormat = [{
78
+ $lhs `,` $rhs attr-dict `:` type($lhs) `,` type($rhs) `->` type($result)
79
+ }];
79
80
81
+ let verifier = [{ return ::verifyShapeOrExtentTensorOp(*this); }];
80
82
let hasFolder = 1;
81
83
82
84
let verifier = [{ return ::verifyShapeOrExtentTensorOp(*this); }];
0 commit comments