[Mlir-commits] [mlir] ec9767e - [mlir] Use OpTraitList to define InferTensorType. NFC

Jacques Pienaar llvmlistbot at llvm.org
Tue Jul 20 18:15:37 PDT 2021


Author: Jacques Pienaar
Date: 2021-07-20T18:15:15-07:00
New Revision: ec9767ef6479714a1cdba6fdd6b4375063a19082

URL: https://github.com/llvm/llvm-project/commit/ec9767ef6479714a1cdba6fdd6b4375063a19082
DIFF: https://github.com/llvm/llvm-project/commit/ec9767ef6479714a1cdba6fdd6b4375063a19082.diff

LOG: [mlir] Use OpTraitList to define InferTensorType. NFC

Added: 
    

Modified: 
    mlir/include/mlir/Interfaces/InferTypeOpInterface.td
    mlir/test/lib/Dialect/Test/TestOps.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
index 8ec3a1256df23..63bbb9b252229 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
@@ -131,8 +131,8 @@ def InferShapedTypeOpInterface : OpInterface<"InferShapedTypeOpInterface"> {
 
 // Convenience class grouping together type and shaped type op interfaces for
 // ops that have tensor return types.
-class InferTensorType<list<string> overridenMethods = []> {
-  list<OpTrait> traits = [
+class InferTensorType<list<string> overridenMethods = []> : OpTraitList<
+  [
     // Op implements infer type op interface.
     InferTypeOpInterface,
     // The op will have methods implementing the ShapedType type inference
@@ -141,10 +141,9 @@ class InferTensorType<list<string> overridenMethods = []> {
     // The op produces tensors and will use the ShapedType type infer interface
     // along with knowledge that it is producing Tensors to infer the type.
     NativeOpTrait<"InferTensorType">
-  ];
-}
-defvar InferTensorTypeWithReify = InferTensorType<[
-    "inferReturnTypeComponents", "reifyReturnTypeShapes"]>;
+  ]>;
+def InferTensorTypeWithReify: OpTraitList<InferTensorType<[
+    "inferReturnTypeComponents", "reifyReturnTypeShapes"]>.traits>;
 
 
 def ReifyRankedShapedTypeOpInterface :

diff  --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index c94ca64ba6958..1e163a9c2fad8 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -565,7 +565,7 @@ def OpWithInferTypeInterfaceOp : TEST_Op<"op_with_infer_type_if", [
 }
 
 def OpWithShapedTypeInferTypeInterfaceOp : TEST_Op<"op_with_shaped_type_infer_type_if",
-      InferTensorTypeWithReify.traits> {
+      [InferTensorTypeWithReify]> {
   let arguments = (ins AnyTensor, AnyTensor);
   let results = (outs AnyTensor);
 }


        


More information about the Mlir-commits mailing list