Hi!
I’m trying to define a permute op working on a 1d vector using Linalg OpDSL in Python; the vector permute op implements the following function for input vector length m*n:
Input vector I[m*n]
Output vector O[m*n]
Strides: m, n
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++)
O[i+m*j] = I[n*i+j]
The operator definition using OpDSL:
@linalg_structured_op
def vector_permute(
K=TensorDef(T, S.KM, S.KN, index_dims=[D.km, D.kn]),
I=TensorDef(T, S.M),
O=TensorDef(U, S.M, output=True),
):
domain(D.km, D.kn)
O[D.km + S.KM * D.kn] = TypeFn.cast_signed(U, I[D.kn + S.KN * D.km])
The error I got:
File "/llvm-project/build/tools/mlir/python_packages/mlir_core/mlir/dialects/linalg/opdsl/lang/emitter.py", line 121, in prepare_common_structured_op
raise ValueError(
ValueError: Expected indexing_maps to use no symbols after replacement and compression but got [AffineMap((d0, d1)[s0, s1] -> (d0, d1)), AffineMap((d0, d1)[s0, s1] -> (d1 + d0 * s1)), AffineMap((d0, d1)[s0, s1] -> (d0 + d1 * s0))]
Does anyone have experience with this? Any feedback is appreciated!