let builders = [
// Build with fully static sizes.
- OpBuilder<(ins "ArrayRef<int64_t>":$staticShape, "Type":$elementType)>,
+ OpBuilder<(ins "ArrayRef<int64_t>":$staticShape, "Type":$elementType,
+ CArg<"Attribute", "{}">:$encoding)>,
// Build with mixed static/dynamic sizes.
OpBuilder<(ins "ArrayRef<int64_t>":$staticShape, "Type":$elementType,
- "ValueRange":$dynamicSizes)>,
+ "ValueRange":$dynamicSizes,
+ CArg<"Attribute", "{}">:$encoding)>,
// Build with mixed static/dynamic sizes.
- OpBuilder<(ins "ArrayRef<OpFoldResult>":$sizes, "Type":$elementType)>
+ OpBuilder<(ins "ArrayRef<OpFoldResult>":$sizes, "Type":$elementType,
+ CArg<"Attribute", "{}">:$encoding)>
];
let hasCanonicalizer = 1;
//===----------------------------------------------------------------------===//
void EmptyOp::build(OpBuilder &builder, OperationState &result,
- ArrayRef<int64_t> staticShape, Type elementType) {
+ ArrayRef<int64_t> staticShape, Type elementType,
+ Attribute encoding) {
assert(all_of(staticShape,
[](int64_t sz) { return !ShapedType::isDynamic(sz); }) &&
"expected only static sizes");
- build(builder, result, staticShape, elementType, {});
+ build(builder, result, staticShape, elementType, ValueRange{}, encoding);
}
void EmptyOp::build(OpBuilder &builder, OperationState &result,
ArrayRef<int64_t> staticShape, Type elementType,
- ValueRange dynamicSizes) {
- auto tensorType = RankedTensorType::get(staticShape, elementType);
+ ValueRange dynamicSizes, Attribute encoding) {
+ auto tensorType = RankedTensorType::get(staticShape, elementType, encoding);
build(builder, result, tensorType, dynamicSizes);
}
void EmptyOp::build(OpBuilder &builder, OperationState &result,
- ArrayRef<OpFoldResult> sizes, Type elementType) {
+ ArrayRef<OpFoldResult> sizes, Type elementType,
+ Attribute encoding) {
SmallVector<int64_t> staticShape;
SmallVector<Value> dynamicSizes;
dispatchIndexOpFoldResults(sizes, dynamicSizes, staticShape,
ShapedType::kDynamicSize);
- build(builder, result, staticShape, elementType, dynamicSizes);
+ build(builder, result, staticShape, elementType, dynamicSizes, encoding);
}
LogicalResult EmptyOp::verify() {
return %0 : tensor<5x?x6xf32>
}
+// CHECK-LABEL: func @empty_with_encoding(
+// CHECK-SAME: %[[sz:.*]]: index
+func.func @empty_with_encoding(%sz: index) -> tensor<5x?x6xf32, "foo"> {
+ // CHECK: tensor.empty(%[[sz]]) : tensor<5x?x6xf32, "foo">
+ %0 = tensor.empty(%sz) : tensor<5x?x6xf32, "foo">
+ return %0 : tensor<5x?x6xf32, "foo">
+}
+
+
// CHECK-LABEL: func @extract(
// CHECK-SAME: %[[TENSOR:.*]]: tensor<?x?x?xf32>,
// CHECK-SAME: %[[INDEX:.*]]: index) {