-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
ATen registrable operator list #38974
Comments
It would be a relatively simple matter to update the codegen/dispatcher to also print out when an operator gets or doesn't get a "bypass" (we call these composite ops internally) so that you know you don't have to implement them. However, I'd prefer not to commit to a specific machine-consumable format of this output, since how composites work in PyTorch are something that we've been actively looking into changing. If you had a spreadsheet that listed everything you needed to change, similar to https://docs.google.com/spreadsheets/d/1dROnZUuR81PAvFLhvAKz23G0ZVK3pSMsBy7XDPSiQjA/edit#gid=1262884632 , would that be sufficient? By the way, @ailzhang as part of XLA has observed to us that sometimes it is useful to be able to override composite operators, because maybe the backend has a fused version. In these situations you have to write a custom backwards as well for the operator in this situation. It would be good if the API made it easy for you to do the right thing in these situations (it doesn't, right now.) |
Thanks for your explanation, @ezyang, allow me check the spreadsheet first. Seems I have no access still, though I received your invitation. Please approve my request on Google Docs. I understand your consideration on composites. BTW, based on PyTorch v1.5, we find some non-composite ops is configured as non-bypass op, like, If all non-composite ops are not bypassed, it might be big help to reduce our efforts on studying ops case by case in PyTorch. Please refer what we do when we rebase PyTorch from v1.4 to v1.5.
|
I am not sure I understand the question. A non-composite op doesn't bypass, period. If you look above at operations where things have swapped between bypass/non-bypass, this is because we have changed internal implementation details. For example, argmin/argmax change is from #32961 and is just us fixing a bug in the codebase. Clamp change is from #37646 where migrated something from TH to ATen, which caused it to stop bypassing (so you can stop implementing As you can see, "what is composite" is an implementation detail, and we often change these under the assumption that it is not BC-breaking (which is true for regular users, but not for you). To stabilize things for extensions, we would have to think about what it means to actually provide a stable API here. If I have a previously composite op and I write a fused implementation for it, does that mean an extension has to now also fuse it? As @ailzhang has pointed out in private correspondence, absolutely not! We should continue to maintain the composite implementation so that it is optional for backends to implement it. These are all good ideas we should do. But we are not really ready for it right now, which is why the experience has been bad. |
@arthuryuan1987 To add a little more context, |
And in your explanation,
Thanks for your explanation, @ezyang, @ailzhang . BTW, we also need to distinguish "dense" and "sparse" to register corresponding backend, DenseBackend, SparceBackend. Have you any suggestion on it? |
@arthuryuan1987 Cool glad to hear that |
Yeah I think sparse is kind of orthogonal. Some ops support sparse. You need to know which ones they are and register them. TBH, |
Thanks, @ailzhang , we will add Thanks, @ezyang , for sure, |
|
Btw, just pointing out a relevant link on how to dump all schemas without relying on codegen: https://github.com/pytorch/pytorch/blob/master/test/backward_compatibility/dump_all_function_schemas.py (should be easily extendable with other information like the presence of "sparse" dispatch). This is more on tech details, we still should agree what part of this information is the actual API contract |
@pbelevich has reminded me that there is a subtle nuance to what I described above:
Composite != "doesn't have a dispatch entry in |
@ezyang Yup |
🚀 Feature
Expose ATen registrable operators information in ATen operator API
Motivation
When implementing a new out-of-source ATen backend extension for PyTorch, we find it is not easy to find out which ATen operators should be registered and implemented. Extension developer expect to work only based on PyTorch ATen operator API. But in fact, we have to distinguish operators in two cases as below, which depends on PyTorch implementation,
Regarding sparse or not, we have to check
native_functions.yaml
.Regarding bypass or not, we have to check
derivatives.yaml
and generated fileVariableTypeEverything.cpp
.Pitch
If PyTorch can expose two operator lists as a part of API to show “sparse or not” and “bypass or not”, the case by case analysis for ATen OP could be avoided when registering Ops for new device. One intuitive idea is to mark them in existing API, for instance of detailed ATen Op schema in
RegistrationDeclarations.h
,{"schema": "aten::add.Tensor(Tensor self, Tensor other, *, Scalar alpha=1) -> Tensor", "compound": "false", "bypass": "false", "sparse": "true"}
{"schema": "aten::add_.Tensor(Tensor(a!) self, Tensor other, *, Scalar alpha=1) -> Tensor(a!)", "compound": "false", "bypass": "false", "sparse": "true"}
{"schema": "aten::add.out(Tensor self, Tensor other, *, Scalar alpha=1, Tensor(a!) out) -> Tensor(a!)", "compound": "false", "bypass": "false", "sparse": "true"}
{"schema": "aten::batch_norm(Tensor input, Tensor? weight, Tensor? bias, Tensor? running_mean, Tensor? running_var, bool training, float momentum, float eps, bool cudnn_enabled) -> Tensor", "compound": "false", "bypass": “true", "sparse": “false"}
The text was updated successfully, but these errors were encountered: