I’ve been running into an issue with Transpose.
I used to use Ops.Transpose on a Tensor to permutate the dimensions.
For example, I had a tensor of shape (1, 256, 256, 3) and but my model only takes into input a tensor of shape (1, 3, 256, 256). Thus in Sentis 1.3.0, I was doing this:
TensorFloat output = ops.Transpose(inputTensor, new int[] {0, 3, 1, 2})
and it would modify the data as well as the shape properly into the output tensor.
But now, I’m currently using IBackend.Transpose which is the same thing but we need to add the output tensor in the parameters. But it doesn’t update the shape of the output tensor.
I did a test:
IBackend backend = WorkerFactory.CreateBackend(BackendType.CPU);
TensorShape shape = new TensorShape(2, 3);
float[] srcData = { 1, 2, 3, 4, 5, 6};
TensorFloat tens = new TensorFloat(shape, srcData);
tens.PrintDataPart(6);
TensorFloat transposedTens = TensorFloat.AllocNoData(shape);
Debug.Log($"Before transpose: tens.shape=" + tens.shape + " transposedTens.shape=" + transposedTens.shape);
backend.Transpose(tens, transposedTens, new int[] { 1, 0 });
Debug.Log($"After transpose: tens.shape=" + tens.shape + " transposedTens.shape=" + transposedTens.shape);
transposedTens.PrintDataPart(6);
backend.Dispose();
tens.Dispose();
transposedTens.Dispose();
And this is the output:
1 2 3 4 5 6
Before transpose: tens.shape=(2, 3) transposedTens.shape=(2, 3)
After transpose: tens.shape=(2, 3) transposedTens.shape=(2, 3)
1 4 2 5 3 6
The issue I have with the output is that the transposedTens’ shape is unchanged. Shouldn’t it be (3, 2) now ?
I may be completely wrong so please feel free to correct me.