ivy icon indicating copy to clipboard operation
ivy copied to clipboard

Added cartesian_prod to Torch frontend

Open JamieLine opened this issue 2 years ago • 1 comments

Fixes #4128

JamieLine avatar Sep 06 '22 17:09 JamieLine

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.

JamieLine avatar Sep 07 '22 18:09 JamieLine

Re-opening.

JamieLine avatar Sep 14 '22 23:09 JamieLine

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

JamieLine avatar Sep 15 '22 21:09 JamieLine

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.

JamieLine avatar Sep 22 '22 00:09 JamieLine