-
Notifications
You must be signed in to change notification settings - Fork 25.7k
addmv: port to structured kernels, improve error checks
#55746
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
💊 CI failures summary and remediationsAs of commit 57ee700 (more details on the Dr. CI page):
🕵️ 1 new failure recognized by patternsThe following CI failures do not appear to be due to upstream breakages:
|
| std::array<int64_t, 1> out_size{mat.sizes()[0]}; | ||
| set_output(out_size, mat.options()); | ||
| auto result = maybe_get_output(); | ||
| //this check can fire for inplace op only, for all other versions result is guaranteed to be correct size |
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.
note for reviewers: maybe we should update inplace structured codegen to perform this check. TensorIterator checks that inplace output is not broadcasted, so for TI-based structured kernels there would be duplication
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.
Hmm, I think I agree I'd prefer just checking that self and set_output have the same size. Should be easy enough to add, and similar to the out tests we added earlier. I definitely don't like the maybe_get_output call here (it is in fact guaranteed to give an output because you called set_output earlier, and this isn't actually part of the intended public contract.)
|
|
||
| Tensor &mv_out(const Tensor &self, const Tensor &vec, Tensor& result) { | ||
| return native::addmv_out(result, self, vec, 0, 1, result); | ||
| return at::addmv_out(result, result, self, vec, 0, 1); |
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.
this adds another dispatch, but I don't see how it can be avoided.
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.
Don't worry, weren't you and mruberry planning to fix this? ;) #50953
Just use a |
196101f to
8dbafcc
Compare
| if (betaval == 0.0) { | ||
| result.zero_(); | ||
| } else { | ||
| at::mul_out( |
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.
neither at::native::mul_out nor at::cpu::mul_out work here, so another dispatch it is
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.
what about at::cuda::mul_out 8)
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.
"at::cuda" has no member "mul_out" - do I need some includes?
|
|
||
| void propagate_names_for_addmv( | ||
| Tensor& result, | ||
| std::vector<Dimname> propagate_names_for_addmv( |
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.
consider using a dimvector here
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.
That would require changing all functions using unify_from_right (because it returns std::vector), better done as a separate PR
| //in addmv, because addmv expects self to satisfy proper conditions | ||
| //to avoid this, supply correctly sized self, its contents doesn't matter because beta is 0 | ||
| if (result.dim() > 1 || (result.numel() != self.size(0) || result.numel() !=1)) { | ||
| Tensor self_addmv = at::empty({self.size(0)}, self.options()); |
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.
Ick, we probably shouldn't implement it this way (preexisting condition, carry on...)
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.
This is a great job, thank you!
|
@ngimel has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: Per title I've revamped size checks a bit to provide better error message if `self` is of the wrong size, also added check that inplace variant has correct `self` size Ref: pytorch#55070 Pull Request resolved: pytorch#55746 Reviewed By: ezyang Differential Revision: D27782980 Pulled By: ngimel fbshipit-source-id: 6ba949b682b8fd1170d0304da0ed348dd1a7b8c7
addmv: pory to structured kernels
addmv: pory to structured kernelsaddmv: port to structured kernels, improve error checks
…xed before (#61579) Summary: This PR: 1. Removes `test_out` skip: it's not needed anymore after it was fixed in #55746. This should also close #55589. 2. Removes `test_variant_consistency_eager` skip, it was added by mistake in #55771. 3. Refines `sample_inputs_addmv` function, the updated function should now be cleaner and easy to read. cc: mruberry Pull Request resolved: #61579 Reviewed By: gchanan Differential Revision: D29709674 Pulled By: mruberry fbshipit-source-id: 9b975c024777efdd33c6b9444b0b36e0eab85c03
Per title
I've revamped size checks a bit to provide better error message if
selfis of the wrong size, also added check that inplace variant has correctselfsizeRef: #55070