%1 = shape.const_shape [1, 2, 3]
```
}];
- let arguments = (ins I64ElementsAttr:$shape);
+ let arguments = (ins IndexElementsAttr:$shape);
let results = (outs Shape_ShapeType:$result);
// TODO: Move this to main so that all shape ops implement these.
let builders = [
// Builder that allows passing a simple integer instead of an IntegerAttr.
OpBuilder<
- [{
- OpBuilder &builder, OperationState &result,
- Value shape, int64_t dim
- }],
- [{
- build(builder, result, shape, builder.getI64IntegerAttr(dim));
- }]
+ [{OpBuilder &builder, OperationState &result, Value shape, int64_t dim}],
+ [{build(builder, result, shape, builder.getI64IntegerAttr(dim));}]
>
];
if (!OpTrait::util::getBroadcastedShape(lhsShape, rhsShape, resultShape))
return nullptr;
Builder builder(getContext());
- return builder.getI64TensorAttr(resultShape);
+ return builder.getIndexTensorAttr(resultShape);
}
//===----------------------------------------------------------------------===//
ints.push_back(attr.getInt());
}
Builder &builder = parser.getBuilder();
- result.addAttribute("shape", builder.getI64TensorAttr(ints));
+ result.addAttribute("shape", builder.getIndexTensorAttr(ints));
result.types.push_back(ShapeType::get(builder.getContext()));
return success();
for (auto attr : operands)
extents.push_back(attr.cast<IntegerAttr>().getInt());
Builder builder(getContext());
- return builder.getI64TensorAttr(extents);
+ return builder.getIndexTensorAttr(extents);
}
//===----------------------------------------------------------------------===//
// TODO: Constant fold this to some kind of constant error.
if (dimToGet >= (uint64_t)elements.getNumElements())
return nullptr;
- // This is a little inconvenient because getValue returns an IntegerAttr
- // that is not of IndexType, but the result here needs to be of
- // IndexType.
- // TODO: Make ConstShapeOp hold an tensor of index instead of i64.
- Builder builder(getContext());
- return builder.getIntegerAttr(
- builder.getIndexType(),
- elements.getValue<IntegerAttr>({dimToGet}).getInt());
+ return elements.getValue({dimToGet});
}
//===----------------------------------------------------------------------===//
if (!type || !type.hasStaticShape())
return nullptr;
Builder builder(getContext());
- return builder.getI64TensorAttr(type.getShape());
+ return builder.getIndexTensorAttr(type.getShape());
}
//===----------------------------------------------------------------------===//
if (splitPoint < 0)
splitPoint += shape.size();
Builder builder(operands[0].getContext());
- results.push_back(builder.getI64TensorAttr(shape.take_front(splitPoint)));
- results.push_back(builder.getI64TensorAttr(shape.drop_front(splitPoint)));
+ results.push_back(builder.getIndexTensorAttr(shape.take_front(splitPoint)));
+ results.push_back(builder.getIndexTensorAttr(shape.drop_front(splitPoint)));
return success();
}
resultShape.append(lhsShape.begin(), lhsShape.end());
resultShape.append(rhsShape.begin(), rhsShape.end());
Builder builder(getContext());
- return builder.getI64TensorAttr(resultShape);
+ return builder.getIndexTensorAttr(resultShape);
}
//===----------------------------------------------------------------------===//
// CHECK: shape.const_shape [2, 3]
// CHECK: shape.const_shape [4, 5]
%c2 = constant 2 : i32
- %0 = "shape.const_shape"() {shape = dense<[2, 3, 4, 5]> : tensor<4xi64>} : () -> !shape.shape
+ %0 = shape.const_shape [2, 3, 4, 5]
%head, %tail = "shape.split_at"(%0, %c2) : (!shape.shape, i32) -> (!shape.shape, !shape.shape)
return %head, %tail : !shape.shape, !shape.shape
// CHECK: shape.const_shape [2, 3, 4]
// CHECK: shape.const_shape [5]
%c-1 = constant -1 : i32
- %0 = "shape.const_shape"() {shape = dense<[2, 3, 4, 5]> : tensor<4xi64>} : () -> !shape.shape
+ %0 = shape.const_shape [2, 3, 4, 5]
%head, %tail = "shape.split_at"(%0, %c-1) : (!shape.shape, i32) -> (!shape.shape, !shape.shape)
return %head, %tail : !shape.shape, !shape.shape
}
func @f() -> (!shape.shape, !shape.shape) {
// CHECK: shape.split_at
%c5 = constant 5 : i32
- %0 = "shape.const_shape"() {shape = dense<[2, 3, 4, 5]> : tensor<4xi64>} : () -> !shape.shape
+ %0 = shape.const_shape [2, 3, 4, 5]
%head, %tail = "shape.split_at"(%0, %c5) : (!shape.shape, i32) -> (!shape.shape, !shape.shape)
return %head, %tail : !shape.shape, !shape.shape
}