pytorch/torchgen
Mengwei Liu 0721a394b6 [executorch][kernel reg] Allow kernel manual registration (#110086)
Summary:
Exposing a codegen mode for generating a hook for user to register their kernels.

If we pass `--manual-registration` flag to `gen_executorch.py`, we will generate the following files:
1. RegisterKernels.h which declares a `register_all_kernels()` API inside `torch::executor` namespace.
2. RegisterKernelsEverything.cpp which implements `register_all_kernels()` by defining an array of generated kernels.

This way user can depend on the library declared by `executorch_generated_lib` macro (with `manual_registration=True`) and be able to include `RegisterKernels.h`. Then they can manually call `register_all_kernels()` instead of relying on C++ static initialization mechanism which is not available in some embedded systems.

Test Plan:
Rely on the unit test:

```
buck2 test fbcode//executorch/runtime/kernel/test:test_kernel_manual_registration
```

Reviewed By: cccclai

Differential Revision: D49439673

Pull Request resolved: https://github.com/pytorch/pytorch/pull/110086
Approved by: https://github.com/cccclai
2023-09-27 16:04:20 +00:00
..
api [BE] use DeviceIndex instead of int64_t for related device interfaces (#103068) 2023-08-25 20:16:14 +00:00
decompositions
dest Remove ExclusivelyOwned from register_dispatch_key (#106791) 2023-08-11 21:04:33 +00:00
executorch [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
fuse_attention_patterns Serialize Remaining Patterns (#108917) 2023-09-20 05:39:23 +00:00
operator_versions [BE]: Update Ruff to 0.0.280 (#105724) 2023-07-22 23:03:34 +00:00
selective_build [BE] f-stringify torch/ and scripts (#105538) 2023-07-21 19:35:24 +00:00
shape_functions
static_runtime sparse.mm backward: performance improvements (#94991) 2023-06-12 20:57:29 +00:00
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
context.py [Specialized Kernel] Propagate Specialized Kernel Support through ComputeCodegenUnboxedKernels (#103113) 2023-06-14 10:18:16 +00:00
gen.py [BE]: Enable ruff rules PIE807 and PIE810 (#106218) 2023-07-28 22:35:56 +00:00
gen_backend_stubs.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
gen_executorch.py [executorch][kernel reg] Allow kernel manual registration (#110086) 2023-09-27 16:04:20 +00:00
gen_functionalization_type.py REDO of dropout support for mem eff #102038 (#103704) 2023-06-26 23:05:03 +00:00
gen_lazy_tensor.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
gen_vmap_plumbing.py
local.py
model.py Make FunctionalTensor subclass to be more like functorch (interaction with ZeroTensor + Conjugate key) (#109023) 2023-09-22 07:09:04 +00:00
native_function_generation.py [export] Refactor constrain_as_value and constrain_as_size (#106591) 2023-08-15 05:41:43 +00:00
utils.py [BE] Enable ruff's UP rules and autoformat torchgen/ (#105423) 2023-07-18 06:44:20 +00:00
yaml_utils.py [Reland] Update mypy to 1.4.1 (#105227) 2023-07-15 20:30:20 +00:00