Arguments in tosa.transpose

Hello everyone,
I am looking at the tosa.transpose operation and I have questions regarding the ‘perms’ attribute.
I found examples in the test cases of MLIR that uses perms both as an attribute and operand
for example,

func @transpose_nofold(%arg0: tensor<3x3xf32>) -> tensor<3x3xf32> {
  // CHECK: "tosa.transpose"
  %0 = arith.constant dense<[1, 0]> : tensor<2xi32>
  %1 = "tosa.transpose"(%arg0, %0) { perms = [1, 0] }: (tensor<3x3xf32>, tensor<2xi32>) -> tensor<3x3xf32>
  return %1 : tensor<3x3xf32>


func @transpose_fold(%arg0: tensor<3x4xf32>) -> tensor<3x4xf32> {
  // CHECK: return %arg0
  %0 = arith.constant dense<[0, 1]> : tensor<2xi32>
  %1 = "tosa.transpose"(%arg0, %0) { perms = [1, 0] }: (tensor<3x4xf32>, tensor<2xi32>) -> tensor<3x4xf32>
  return %1 : tensor<3x4xf32>

Looking at the code, the perms passed as an operand (%0 in the above test cases) should be used for permuting the dimensions of %arg0.
I am curious about how the ‘perms’ attribute is used in the operation.
Thank you!


It looks like this is a bug in that test. The attribute perms isn’t used as far as I can tell. I removed the { perms … } from the tosa.transpose lines, and the tests still passed. The other transpose tests use the operand form of the perms argument.

If you’re looking for what the TOSA perms argument is supposed to do, the spec (linked off of :zap: TOSA ( is the best place to look. It has pseudocode for all of the operators which shows how the arguments are used.

Thank you for your reply and the link!