[llvm] [mlir] [MLIR] Generalize expand_shape to take shape as explicit input (PR #90040)

Oleksandr Alex Zinenko via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 10:12:04 PDT 2024


================
@@ -2280,14 +2332,28 @@ LogicalResult ExpandShapeOp::verify() {
     return emitOpError("expected expanded type to be ")
            << *expectedResultType << " but found " << resultType;
 
+  if ((int64_t)getStaticOutputShape().size() != resultType.getRank())
+    return emitOpError("expected number of static shape bounds to be equal to "
+                       "the output rank (")
+           << resultType.getRank() << ") but found "
+           << getStaticOutputShape().size() << " inputs instead";
+
+  if ((int64_t)getOutputShape().size() !=
+      llvm::count(getStaticOutputShape(), ShapedType::kDynamic))
+    return emitOpError("mismatch in dynamic dims in output_shape and "
+                       "static_output_shape: static_output_shape has ")
+           << llvm::count(getStaticOutputShape(), ShapedType::kDynamic)
+           << " dynamic dims while output_shape has " << getOutputShape().size()
+           << " values";
+
----------------
ftynse wrote:

You mean the assembly syntax? Is it still possible to trigger this message by writing the op using the generic syntax? If not, it cannot be triggered on user-supplied IR and should become an assertion.

https://github.com/llvm/llvm-project/pull/90040


More information about the llvm-commits mailing list