Skip to content

[mlir][ods] Document InferTypeOpInterface behavior. #145060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 21, 2025
Merged

Conversation

jpienaar
Copy link
Member

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

Confused user again recently and I couldn't find where we documented it, figured this is discoverable.
@llvmbot llvmbot added the mlir label Jun 20, 2025
@llvmbot
Copy link
Member

llvmbot commented Jun 20, 2025

@llvm/pr-subscribers-mlir

Author: Jacques Pienaar (jpienaar)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/145060.diff

1 Files Affected:

  • (modified) mlir/include/mlir/Interfaces/InferTypeOpInterface.td (+14-6)
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 different 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 different 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),

@jpienaar jpienaar merged commit 4c2b931 into llvm:main Jun 21, 2025
9 checks passed
Jaddyen pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 23, 2025
Confused folks again recently and I couldn't find where we documented
it, figured this is more discoverable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants