Skip to content

Commit 4c2b931

Browse files
authored
[mlir][ods] Document InferTypeOpInterface behavior. (#145060)
Confused folks again recently and I couldn't find where we documented it, figured this is more discoverable.
1 parent 7031280 commit 4c2b931

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

mlir/include/mlir/Interfaces/InferTypeOpInterface.td

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99
// This file contains a set of interfaces that can be used to define information
1010
// related to type inference.
1111
//
12+
// This interface is also used by ODS to create builders for operations that
13+
// do not require result type to be specified. Including this interface in
14+
// dialect op definitions is sufficient to result in such builders being
15+
// automatically generated for trivially buildable result types.
16+
//
1217
//===----------------------------------------------------------------------===//
1318

1419
#ifndef MLIR_INFERTYPEOPINTERFACE
@@ -37,6 +42,10 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
3742
and the regions of the op. Be aware that this method is supposed to be
3843
called with valid arguments, e.g., operands are verified, or it may result
3944
in an undefined behavior.
45+
46+
The inferred result types may be less precise than what may be specified
47+
directly or produced by refinement, but are required to be compatible
48+
(as defined by the op's compatibility function).
4049
}],
4150
/*retTy=*/"::llvm::LogicalResult",
4251
/*methodName=*/"inferReturnTypes",
@@ -67,10 +76,10 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
6776
The return types may be elided or specific elements be null for elements
6877
that should just be returned but not verified.
6978

70-
Because this method can be called from within different stages of IR
71-
verification, implementations should not assume the arguments to
72-
represent fully valid IR and are responsible for checking inputs for
73-
validity to the degree necessary to perform the return type inference.
79+
This method may be called from within different stages of IR verification,
80+
implementations should not assume the arguments to represent fully valid
81+
IR and are responsible for checking inputs for validity to the degree
82+
necessary to perform the return type inference.
7483
}],
7584
/*retTy=*/"::llvm::LogicalResult",
7685
/*methodName=*/"refineReturnTypes",
@@ -100,8 +109,7 @@ def InferTypeOpInterface : OpInterface<"InferTypeOpInterface"> {
100109
}]
101110
>,
102111
StaticInterfaceMethod<
103-
/*desc=*/"Returns whether two array of types are compatible result types"
104-
" for an op.",
112+
/*desc=*/"Returns whether two type ranges are compatible result types.",
105113
/*retTy=*/"bool",
106114
/*methodName=*/"isCompatibleReturnTypes",
107115
/*args=*/(ins "::mlir::TypeRange":$lhs, "::mlir::TypeRange":$rhs),

0 commit comments

Comments
 (0)