Skip to content

Conversation

huiguoo
Copy link
Contributor

@huiguoo huiguoo commented Jun 3, 2021

Stack from ghstack:

Differential Revision: D28854806

@facebook-github-bot facebook-github-bot added oncall: jit Add this issue/PR to JIT oncall triage queue cla signed labels Jun 3, 2021
@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Jun 3, 2021

💊 CI failures summary and remediations

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


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

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.

huiguoo added a commit that referenced this pull request Jun 3, 2021
ghstack-source-id: 617cd9d
Pull Request resolved: #59350
@huiguoo
Copy link
Contributor Author

huiguoo commented Jun 3, 2021

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

@huiguoo huiguoo requested review from ZolotukhinM and navahgar June 3, 2021 00:04
py::return_value_policy::reference);

te.def(
"Compute2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not add this as another case under the def above for Compute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As the case of dim_args.size()>4? It seems unnecessary (dim_args.size()>4) to use Compute2-like API (function argument being a vector). Also, we may not want the user to check the number of dim_args before they use Compute.

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't mean for the user to check the number of dim_args. The user will just pass a func to Compute. That func either takes in 1, 2, 3, or 4 parameters (as is currently the case) or takes in a vector (which is the case you are trying to add) if the number of args is > 4.

Are you suggesting that the user might want to use this API even when the number of args is <= 4?

I am just trying to see if having a new function name Compute2 does not create more confusion.

Copy link

@ZolotukhinM ZolotukhinM Jun 3, 2021

Choose a reason for hiding this comment

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

I think it could be confusing that for 4 arguments I'd need to pass a function that takes 4 arguments and for 5 arguments I'd need to pass a function that takes one argument (a list with 5 elements). From that perspective having a separate function, like Compute2, makes sense to me since I don't see a way to distinguish these two cases inside Compute. That said, I think Compute2 could use a better name.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually any function that special cases for smaller number of arguments will do that, say, for example, have overloaded functions for 1, 2, 3 and 4 arguments, and another overload that takes a list (for args > 4). That is pretty normal IMO. Having a different method is more confusing for me.

But if you both prefer this approach, I don't have a problem.

Choose a reason for hiding this comment

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

Mm, I'd like to have the overloaded function here too, but I'm not sure it's possible because of the fact that we're using py::function here and that's what in theory should be used to resolve the overload. In other words, we cannot distinguish when a user passes a function that expects a list and a function that expects 4 parameters. And since we can not distinguish that, we cannot resolve the overload, and hence we need to have explicitly different functions for these two cases. Am I missing something? I just don't see how this would work otherwise: if I provide a function that accepts a list and then happen to pass a list with 2 elements, then the current implementation will try to expand the list into two parameters and call the function with two separate parameters, which will not work.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, yeah, okay. I see the problem with this approach now. Thanks for clarifying.

Copy link
Contributor

@navahgar navahgar left a comment

Choose a reason for hiding this comment

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

LGTM

py::return_value_policy::reference);

te.def(
"Compute2",
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, yeah, okay. I see the problem with this approach now. Thanks for clarifying.

@huiguoo
Copy link
Contributor Author

huiguoo commented Jun 3, 2021

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

@facebook-github-bot
Copy link
Contributor

@huiguoo merged this pull request in c717ce6.

@facebook-github-bot facebook-github-bot deleted the gh/huiguoo/27/head branch June 7, 2021 14:17
deniskokarev pushed a commit to deniskokarev/pytorch that referenced this pull request Jun 9, 2021
Summary: Pull Request resolved: pytorch#59350

Test Plan: Imported from OSS

Reviewed By: mruberry

Differential Revision: D28854806

Pulled By: huiguoo

fbshipit-source-id: b9091f9183249257aedc1eafb1992e0faf5dea82
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla signed Merged oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants