Skip to content

Manual kernel registration to include library names in API #11221

Open
@larryliu0820

Description

@larryliu0820

🚀 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomersmodule: runtimeIssues related to the core runtime and code under runtime/

    Type

    No type

    Projects

    Status

    To triage

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions