[Mlir-commits] [mlir] [mlir][bufferization] Empty tensor elimination based on SubsetOpInterface (PR #65766)

Martin Erhart llvmlistbot at llvm.org
Tue Sep 12 05:04:15 PDT 2023


================
@@ -96,6 +96,50 @@ def SubsetOpInterface : OpInterface<"SubsetOpInterface"> {
             "::mlir::Value":$candidate,
             "::llvm::function_ref<bool(Value, Value)>":$equivalenceFn)
       >,
+      InterfaceMethod<
+        /*desc=*/[{
+          Return the subset of the destination tensor that this operation
+          inserts into.
+
+          Example:
+          ```
+          // SubsetOpInterface op:
+          %0 = tensor.insert_slice %t0 into %t1[%pos][5][1]
+              : tensor<5xf32> into tensor<?xf32>
+          // Subset (built by this function):
+          %1 = tensor.extract_slice %t1[%pos][5][1]
+              : tensor<?xf32> to tensor<5xf32>
+          ```
+
+          Note: Implementations do not necessarily have to build new IR. They
+          may return existing SSA values.
+        }],
+        /*retType=*/"::mlir::Value",
+        /*methodName=*/"getSubset",
+        /*args=*/(ins "::mlir::OpBuilder &":$builder, "Location":$loc),
+        /*methodBody=*/"",
+        /*defaultImplementation=*/[{
+          llvm_unreachable("getSubset not implemented");
+        }]
----------------
maerhart wrote:

Why make implementation optional (also for the method below)?

https://github.com/llvm/llvm-project/pull/65766


More information about the Mlir-commits mailing list