[Mlir-commits] [mlir] [mlir] NFC: Clarify documentation on InferShapedTypeOpInterface::inferReturnTypeComponents (PR #70350)
Jacques Pienaar
llvmlistbot at llvm.org
Fri Oct 27 10:55:14 PDT 2023
================
@@ -142,6 +142,9 @@ def InferShapedTypeOpInterface : OpInterface<"InferShapedTypeOpInterface"> {
Unknown (e.g., unranked) shape and nullptrs for element type and attribute
may be returned by this function while returning success. E.g., partial
population of components is not error condition.
+
+ 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.
----------------
jpienaar wrote:
It's an ordering question: the verifier one can set different orderings, and AFAIK verification of number of operands etc occur before trait verification (but please check me on this) so that it does handle many cases in the verifier. But its also called in the builder, and in the builder those have often not been verified yet (that could be improved with the OpAdaptor verifier).
These do assume the IR/operands are valid, but that's also true for almost every function and interface (calling on invalid IR is rather unbounded set). Now valid here has an asterisk, valid doesn't for example mean the types are correct, just that it has the correct number of arguments say and could fail gracefully here. Rank verification and the like also happen inside this quite oftn (as verifying the input rank is often done along with computing the result). Ideally we'd have more of these declaratively and generate these functions more so that the ordering can be taken care off by the pre- and post-conditions.
https://github.com/llvm/llvm-project/pull/70350
More information about the Mlir-commits
mailing list