[Mlir-commits] [mlir] [mlir][tosa] Change Transpose perms operand to attribute (PR #128115)

Georgios Pinitas llvmlistbot at llvm.org
Mon Feb 24 10:17:32 PST 2025


================
@@ -1467,75 +1436,61 @@ LogicalResult tosa::TransposeOp::inferReturnTypeComponents(
 
 LogicalResult tosa::TransposeOp::verify() {
   TensorType inputType = getInput1().getType();
-  TensorType permType = getPerms().getType();
   TensorType outputType = getOutput().getType();
+  const llvm::ArrayRef<int32_t> constantPerms = getPerms();
 
-  if (permType.hasRank() && permType.getRank() != 1)
-    return emitOpError()
-           << "expected permutation tensor to be rank 1 but got rank "
-           << permType.getRank();
-  if (inputType.hasRank() && permType.hasRank())
-    if (!permType.isDynamicDim(0) &&
-        permType.getDimSize(0) != inputType.getRank())
-      return emitOpError() << "expected permutation tensor dim 0 to have size "
+  if (inputType.hasRank())
+    if (constantPerms.size() != static_cast<size_t>(inputType.getRank()))
+      return emitOpError() << "expected perms attribute to have size "
                            << inputType.getRank()
                            << " (input rank) but got size "
-                           << permType.getDimSize(0);
+                           << constantPerms.size();
   if (inputType.hasRank() && outputType.hasRank() &&
       inputType.getRank() != outputType.getRank())
     return emitOpError()
            << "expected input tensor rank to equal result tensor rank";
-  if (outputType.hasRank() && permType.hasRank())
-    if (!permType.isDynamicDim(0) &&
-        permType.getDimSize(0) != outputType.getRank())
-      return emitOpError() << "expected permutation tensor dim 0 to have size "
+  if (outputType.hasRank())
----------------
GeorgeARM wrote:

Should we merge the ifs?

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


More information about the Mlir-commits mailing list