pytorch/tools/codegen
francescocastelli cbb2df541a Added check for unsupported dispatch key in codegen (#67961)
Summary:
Added a check for the dispatch keys present in native_function.yaml, they must be part of the fixed set of dispatch keys. If not, signal an error. I also removed two dispatch keys from the function schema copy_ , because they are not supported (SparseHIP, SpareXPU).

Pull Request resolved: https://github.com/pytorch/pytorch/pull/67961

Test Plan:
this function schema (for example) in native_function.yaml
```
- func: native_norm(Tensor self, Scalar p=2) -> Tensor
  dispatch:
    SparseCPU, SparseCUDA, SparseHIP: norm_sparse
```
now generates this error during codegen:  `AssertionError: SparseHIP is not a supported dispatch key.`

Fixes https://github.com/pytorch/pytorch/issues/66190

Reviewed By: albanD

Differential Revision: D34327853

Pulled By: ezyang

fbshipit-source-id: 6959d14a7752aefd025baa482d56547b4ed69b4c
(cherry picked from commit 26bea380af)
2022-02-22 22:31:47 +00:00
..
api Revert D34342689: Revert D34250357: Sync lazy_tensor_staging back to master 2022-02-18 17:31:21 +00:00
dest Revert D34342689: Revert D34250357: Sync lazy_tensor_staging back to master 2022-02-18 17:31:21 +00:00
operator_versions Fix upgrader codegen when constant list is 0 (#72199) 2022-02-03 00:41:03 +00:00
selective_build [Pytorch Edge] Generic Build Features for Selective Build (#67817) 2021-11-09 15:37:21 -08:00
static_runtime [Static Runtime] Add a script to auto-generate out variant dispatchers (#72602) 2022-02-17 16:55:39 +00:00
__init__.py Rewrite of ATen code generator (#42629) 2020-08-31 09:00:22 -07:00
code_template.py Rewrite of ATen code generator (#42629) 2020-08-31 09:00:22 -07:00
context.py avoid error string formatting aten codegen 28s -> 23s (#59848) 2021-06-12 06:58:31 -07:00
gen_backend_stubs.py codegen: do not generate code for dispatch_namespaced_definitions (#69074) 2022-02-16 19:30:38 +00:00
gen_functionalization_type.py Functionalization: Only include headers for required ops (#68690) 2021-12-15 14:29:35 -08:00
gen_lazy_tensor.py Revert D34342689: Revert D34250357: Sync lazy_tensor_staging back to master 2022-02-18 17:31:21 +00:00
gen.py Added check for unsupported dispatch key in codegen (#67961) 2022-02-22 22:31:47 +00:00
local.py [PyTorch] Fix const correctness for resize native functions (#55351) 2021-04-21 14:51:41 -07:00
model.py Added check for unsupported dispatch key in codegen (#67961) 2022-02-22 22:31:47 +00:00
utils.py Codegen: Do less work in dry-runs for sharded files (#69805) 2022-02-02 19:25:16 +00:00