Skip to content

DynamicShim for dlsym user #3136

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

kirklandsign
Copy link
Contributor

Summary:
Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:

  • header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
  • implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.

Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API create_executorch_dynamic_shim and free_executorch_dynamic_shim, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594

Copy link

pytorch-bot bot commented Apr 18, 2024

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/3136

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 7c269e9 with merge base de0c233 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@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 Apr 18, 2024
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 19, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 19, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 19, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 19, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 23, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

kirklandsign added a commit to kirklandsign/executorch that referenced this pull request Apr 23, 2024
Summary:

Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.

Differential Revision: D55025594
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@kirklandsign has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Summary:
Add a shim layer so that users just need the header and load the symbol with dlsym.

we will have two libraries:
- header, where declarations and class (shim) are to be compiled with their codebase statically. Want to keep this minimal.
- implementation, which pulls in the ET libraries and shim implementation. It’s compiled separately as a .so file and they can load and find symbols with dlopen and dlsym.


Note that users only need to compile the header dynamic_shim.h into their code in compile time. dynamic_shim.h contains minimal dependency from ExecuTorch, so it won't impact static time binary size or startup time. The actual implementation dynamic_shim_impl is compiled into a separate shared library, which has all the ExecuTorch libraries. The shared library can be loaded later with dlopen.

For users, they can now only load the so library, and just use dysym to look for exposed API `create_executorch_dynamic_shim` and `free_executorch_dynamic_shim`, and use API code in DynamicShim (as a pointer to an interface), and the DynamicShimImpl will invoke the actual ET Module code in its implementation details.


Reviewed By: kimishpatel

Differential Revision: D55025594

Pulled By: kirklandsign
@facebook-github-bot
Copy link
Contributor

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

@facebook-github-bot
Copy link
Contributor

@kirklandsign merged this pull request in b5bb921.

@mergennachin mergennachin mentioned this pull request Apr 26, 2024
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.

3 participants