Skip to content

Allow kernel manual registration #491

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

Closed
wants to merge 1 commit into from

Conversation

larryliu0820
Copy link
Contributor

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.

Reviewed By: cccclai

Differential Revision: D49439673

@netlify
Copy link

netlify bot commented Sep 26, 2023

Deploy Preview for resplendent-gnome-14e531 canceled.

Name Link
🔨 Latest commit 8a53eef
🔍 Latest deploy log https://app.netlify.com/sites/resplendent-gnome-14e531/deploys/6513557fc479e10008a0ba0d

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 26, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

Summary:
X-link: pytorch/pytorch#110086


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.

Reviewed By: cccclai

Differential Revision: D49439673
larryliu0820 added a commit to larryliu0820/pytorch that referenced this pull request Sep 26, 2023
…0086)

Summary:

X-link: pytorch/executorch#491

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
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D49439673

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 153cf3b.

Gasoonjia pushed a commit that referenced this pull request Jul 30, 2024
* Minimal android app build

* Improve script

* Detect physical device as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants