pytorch
9f873ed7 - [torchgen] support codegen'd C++ API for a mixture of namespaces (#81581)

Commit
2 years ago
[torchgen] support codegen'd C++ API for a mixture of namespaces (#81581) Summary: In #77710 I introduces some hack to allow static dispatch to take namespaces. After we introduced namespace into ops and kernels, we don't have to pass namespace into `static_dispatch()`; instead we will generate ops with the kernel namespace for `Functions.h`. After this diff: If we have a yaml file looking like this: ``` - func: op_1(Tensor(a) self) -> Tensor(a) dispatch: CPU: at::op_1_kernel # ATen kernel - func: op_2(Tensor(a) self) -> Tensor(a) dispatch: CPU: custom::op_2_kernel # custom kernel ``` `Functions.h` will contain the following C++ APIs: ``` TORCH_API inline at::Tensor & op_1(at::Tensor & self) { return at::cpu::op_1_kernel(self); } TORCH_API inline at::Tensor & op_2(at::Tensor & self) { return custom::cpu::op_2_kernel(self); } ``` Test Plan: Rely on CI Differential Revision: D37900753 Pull Request resolved: https://github.com/pytorch/pytorch/pull/81581 Approved by: https://github.com/iseeyuan
Author
Committer
Parents
Loading