-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add C++-only int dim overloads to std-related operations
#40451
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
Conversation
The int->bool conversion taking higher precedence than int->IntArrayRef. So, calling std(0) in c++ wouldn't select the dimension overload.
💊 CI failures summary and remediationsAs of commit 2ad750c (more details on the Dr. CI page): 💚 💚 Looks good so far! There are no failures yet. 💚 💚 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 on the GitHub issue tracker or post in the (internal) Dr. CI Users group. This comment has been revised 3 times. |
| return at::native::var(self, IntArrayRef{dim}); | ||
| } | ||
|
|
||
| inline std::tuple<Tensor,Tensor> var_mean(const Tensor& self, int dim) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be int64_t?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std(0) will only work if the type is an exact match for operator overloading, so dim must be exactly int. I could add more overloads to accept other integral types, but an int overload would still be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be good to explicitly mention this in the comment!
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Fixes gh-40287
The
int -> boolconversion takes higher precedence thanint -> IntArrayRef. So, callingstd(0)in C++ would select thestd(unbiased=False)overload instead.