Hi:
I am trying to add a new operator InvertPermutation
. For an output tensor y
and an input tensor x
, InvertPermutation
computes the following:
y[x[i]] = i for i in [0, 1, ..., len(x) - 1]
Example: invert_permutation([3, 4, 0, 2, 1]) ==> [2, 4, 3, 0, 1]
The tricky part of writing the compute lambda function is that the function’s input iter Var represents the index of the output tensor, while this operation requires that the index of the output tensor should be computed by the input tensor.
So, is there a way to make the lambda funtion’s input Var represents the index of the input tensor? Or is there a way we can iterate the input tensor?
Any suggestions? Thanks a lot