[Mlir-commits] [mlir] 4c2b931 - [mlir][ods] Document InferTypeOpInterface behavior. (#145060)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jun 20 21:43:28 PDT 2025


Author: Jacques Pienaar
Date: 2025-06-20T21:43:25-07:00
New Revision: 4c2b9317f8fc08e2f6ef369a5018ee5b5626cf01

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

LOG: [mlir][ods] Document InferTypeOpInterface behavior. (#145060)

Confused folks again recently and I couldn't find where we documented
it, figured this is more discoverable.

Added: 
    

Modified: 
    mlir/include/mlir/Interfaces/InferTypeOpInterface.td

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
index 92d4a99ecb7f5..49925fe7701c9 100644
--- a/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
+++ b/mlir/include/mlir/Interfaces/InferTypeOpInterface.td
@@ -9,6 +9,11 @@
 // This file contains a set of interfaces that can be used to define information
 // related to type inference.
 //
+// This interface is also used by ODS to create builders for operations that
+// do not require result type to be specified. Including this interface in
+// dialect op definitions is sufficient to result in such builders being
+// automatically generated for trivially buildable result types.
+//
 //===----------------------------------------------------------------------===//
 
 #ifndef MLIR_INFERTYPEOPINTERFACE
@@ -37,6 +42,10 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
       and the regions of the op. Be aware that this method is supposed to be
       called with valid arguments, e.g., operands are verified, or it may result
       in an undefined behavior.
+
+      The inferred result types may be less precise than what may be specified
+      directly or produced by refinement, but are required to be compatible
+      (as defined by the op's compatibility function).
       }],
       /*retTy=*/"::llvm::LogicalResult",
       /*methodName=*/"inferReturnTypes",
@@ -67,10 +76,10 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
       The return types may be elided or specific elements be null for elements
       that should just be returned but not verified.
 
-      Because this method can be called from within 
diff erent stages of IR
-      verification, implementations should not assume the arguments to
-      represent fully valid IR and are responsible for checking inputs for
-      validity to the degree necessary to perform the return type inference.
+      This method may be called from within 
diff erent stages of IR verification,
+      implementations should not assume the arguments to represent fully valid
+      IR and are responsible for checking inputs for validity to the degree
+      necessary to perform the return type inference.
       }],
       /*retTy=*/"::llvm::LogicalResult",
       /*methodName=*/"refineReturnTypes",
@@ -100,8 +109,7 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
       }]
     >,
     StaticInterfaceMethod<
-      /*desc=*/"Returns whether two array of types are compatible result types"
-               " for an op.",
+      /*desc=*/"Returns whether two type ranges are compatible result types.",
       /*retTy=*/"bool",
       /*methodName=*/"isCompatibleReturnTypes",
       /*args=*/(ins "::mlir::TypeRange":$lhs, "::mlir::TypeRange":$rhs),


        


More information about the Mlir-commits mailing list