pytorch / pytorch/executorch

Manual kernel registration to include library names in API

Open
#11,221 6 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

good first issue module: runtime
Dominant language
Python
Stars
5k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
581

Description

🚀 The feature, motivation and pitch

This request came from @shoumikhin.

For developers on Xcode, they wanted to be able to pick and use kernels_optimized, kernels_quantized and kernels_custom libraries in their application.

Image

The caveat is that since they all use static initialization kernel registration mechanism, all of these libraries requires --force_load linker flag here:

https://github.com/pytorch/executorch/blob/main/examples/demo-apps/apple_ios/LLaMA/LLaMA/SupportingFiles/Release.xcconfig#L8-L14

This causes churns for app developers because they will have to add these linker flags manually and it's not an out of the box experience.

To fix this, we wanted to allow user to pass in a library name to codegen and generate a register_<lib_name>_kernels API.

Currently we trigger selective build using this API:

https://github.com/pytorch/executorch/blob/main/tools/cmake/Codegen.cmake#L63C10-L63C39

We want to add a new argument LIB_NAME and pass the value all the way down into the python script here:

https://github.com/pytorch/executorch/blob/main/tools/cmake/Codegen.cmake#L95

Then inside the python script, add an optional argument to take the lib name and optionally generate register_<lib_name>_kernels API.

Alternatives

No response

Additional context

No response

RFC (Optional)

No response

cc @JacobSzwejbka @lucylq

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with tools/cmake/Codegen.cmake at the selective-build API and LIB_NAME handoff, then follow the linked Python codegen script. Check how kernel registration is currently generated and define the optional library-name path. Done means callers can pass LIB_NAME and receive a register_<lib_name>_kernels API for libraries such as kernels_optimized, kernels_quantized, and kernels_custom.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, python
Domain
build-system, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.