Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add torch.meshgrid to torch frontend #11560

Closed
wants to merge 2 commits into from
Closed

add torch.meshgrid to torch frontend #11560

wants to merge 2 commits into from

Conversation

elreweidy
Copy link
Contributor

close #11227

@ivy-leaves ivy-leaves added the PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist label Mar 2, 2023
@Infrared1029
Copy link
Contributor

Hi Ahmed! thanks again for your contribution to ivy! as the tests appear to be failing, i'll add a few comments that hopefully help:)

@@ -35,6 +35,11 @@ def roll(input, shifts, dims=None):
return ivy.roll(input, shifts, axis=dims)


@to_ivy_arrays_and_back
def meshgrid(*tensors, indexing=None):
return ivy.meshgrid(*tensors, indexing=indexing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch's meshgrid returns a tuple so cast the output to a tuple instead of a list, (this also fixes the type issues and output length issues)

test_flags,
):
dtypes, tensors = dtypes_and_tensors
if isinstance(dtypes, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the if else statement here is actually not needed as the output is always a list, also no need to cast the output to a numpy array, it is already one, no need to cast the type either, just keep it as kwargs = { f"tensor{i}": tensor for i, tensor in enumerate(tensors) }

else:
args = {"tensor": np.array(tensors, dtype=dtypes)}
kwargs['indexing'] = indexing
test_flags.num_positional_args = len(tensors) + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no need for the +1 in line 174, len(tensor) should be enough

@Infrared1029
Copy link
Contributor

Hopefully, everything will run with no errors after these little tweaks, and we should be good to merge!

@elreweidy
Copy link
Contributor Author

thank you so much, Yasser, I will try these changes asap in a different PR, this branch got some problems for me

@elreweidy elreweidy closed this Mar 2, 2023
@Infrared1029
Copy link
Contributor

thank you so much, Yasser, I will try these changes asap in a different PR, this branch got some problems for me

No worries! see you there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PyTorch Frontend Developing the PyTorch Frontend, checklist triggered by commenting add_frontend_checklist
Projects
None yet
Development

Successfully merging this pull request may close these issues.

meshgrid
3 participants