KEMBAR78
add torch.meshgrid() OpInfo by dagitses · Pull Request #62720 · pytorch/pytorch · GitHub
Skip to content

Conversation

@dagitses
Copy link
Collaborator

@dagitses dagitses commented Aug 4, 2021

Fixes #62719

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Aug 4, 2021

🔗 Helpful links

💊 CI failures summary and remediations

As of commit aa6973e (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-scanned failure(s)

ci.pytorch.org: 1 failed


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch 3 times, most recently from c885221 to 4e8e658 Compare August 4, 2021 20:30
@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch 6 times, most recently from e5f5daa to 897ba90 Compare August 9, 2021 17:13
@dagitses dagitses marked this pull request as ready for review August 9, 2021 17:16
@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch 4 times, most recently from c3672cf to 3d1b67a Compare August 10, 2021 00:48
@dagitses dagitses changed the base branch from master to dagitses/meshgrid-doc August 10, 2021 01:53
@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch from 3d1b67a to 4ff55ce Compare August 11, 2021 14:42
@mruberry mruberry requested review from mruberry and removed request for janeyx99, mingzhe09088 and zhaojuanmao August 11, 2021 16:11


def sample_inputs_meshgrid(
calling_convention: str) -> Callable[[OpInfo, torch.device, torch.dtype, bool], List[SampleInput]]:
Copy link
Collaborator

@mruberry mruberry Aug 11, 2021

Choose a reason for hiding this comment

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

Adding all this type information looks time-consuming, did the system make you do it? We should probably stop linting this file if so

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't remember if it made me do it. It seems unlikely given that most of the file is not type annotated.


def sample_inputs(op_info: OpInfo, device: torch.device, dtype: torch.dtype,
requires_grad: bool) -> List[SampleInput]:
Z = () # note: torch.rand(()) yields a random 0D tensor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Z seems like a fine addition to the S M and L defined at the global scope

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done. i have some concern that Z is not necessarily interchangeable with the other sizes, since it represents a full shape, whereas sometimes S et al. are used as the length of a single dimension.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Fair point, but from that perspective I'd suggest simply not defining it and always writing (), then, because that concern is also a local concern

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

True, it is a local concern. S here is also a local, not the value from above. Do you think that having two local constants S and Z here would be inappropriate?

S = torch.Size([3])
Z = torch.Size([])

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer not shadowing the global for readability, especially not shadowing it with a very similar value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed to locals named SCALAR and VECTOR

Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Hey @dagitses! Overall looks good. I made some notes about possibly simplifying the sample inputs.

@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch 4 times, most recently from 95bbdc6 to 65ddedf Compare August 14, 2021 09:53
'Unsupported variant, must be one of {"variadic", "list"}. '
f'Got "{variant}".')

SCALAR = torch.Size([])
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure these are really improving readability here but I guess it's OK

@mruberry mruberry self-requested a review August 16, 2021 17:28
Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Cool!

@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch from 65ddedf to 5c980fe Compare August 16, 2021 17:44
@facebook-github-bot
Copy link
Contributor

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch from 5c980fe to fb4ef92 Compare August 17, 2021 02:28
@facebook-github-bot
Copy link
Contributor

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@dagitses dagitses force-pushed the dagitses/#62719/meshgrid-opinfo branch from fb4ef92 to aa6973e Compare August 17, 2021 02:30
@facebook-github-bot
Copy link
Contributor

@dagitses has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@dagitses merged this pull request in cae5ddc.

@dagitses dagitses deleted the dagitses/#62719/meshgrid-opinfo branch August 17, 2021 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.meshgrid requires an OpInfo test

3 participants