tensorly
tensorly copied to clipboard
Jax test for permute factors
Describe the bug
After recent updates, testing with jax backend fails when indexing with lists in cp_permute_factors. Error occurs when updating weights in line 735. Related issue can be found here.
Steps or Code to Reproduce
import tensorly as tl
tl.set_backend('jax')
indices = [1, 2, 0, 3]
array = tl.tensor([0, 1, 2, 3])
new_array = array[indices]
TypeError: Using a non-tuple sequence for multidimensional indexing is not allowed; use arr[array(seq)] instead of arr[seq].
Expected behavior
If input indices is an array, it works. However, I couldn't find how to fix it in a that way in Tensorly.
import tensorly as tl
tl.set_backend('jax')
indices = [1, 2, 0, 3]
array = tl.tensor([0, 1, 2, 3])
new_array = array[tl.tensor(indices)]
print(new_array)
[1 2 0 3]