ivy
ivy copied to clipboard
Added cartesian_prod to Torch frontend
Fixes #4128
Regarding the comment above the test for cartesian_prod
, the function supports arbitrarily many inputs, but I cannot work out a way to have the test produce arbitrarily many inputs without the test throwing TypeError: expected Tensor as element 0 in argument 0, but got list
when calling the real PyTorch function. I'm not sure if there is something I am missing or if this is a suitable workaround.
Re-opening.
I've added in the test setup to have variable numbers of tensors and improved the implementation of the frontend function itself to use Ivy functions rather than itertools
I had it in there to prevent a case where simultaneously num_arrays==1
and dim_size==1
which was causing crashes, but now I can't replicate this crash and I could put some time in to work out why it isn't crashing now but I don't think it's a good use of time. I think if that bug had persisted then it would be worth the extra strategy (to allow for the valid cases where only one of those values were 1
) but since it is gone I've removed it.
The test is now basically a carbon copy of the meshgrid
test.