diff --git a/CMakeLists.txt b/CMakeLists.txt index 897fdefd14..f027aa406b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -756,6 +756,14 @@ if(EXECUTORCH_BUILD_PYBIND) BUILD_RPATH "@loader_path/../../../torch/lib" INSTALL_RPATH "@loader_path/../../../torch/lib" ) + else() + set_target_properties( + portable_lib + PROPERTIES # Assume that this library will be installed in + # `site-packages/executorch/extension/pybindings`, and that + # the custom_ops_aot_lib should be found with relative path. + BUILD_RPATH "$ORIGIN:$ORIGIN/../../examplesmodels/llama2/custom_ops" + ) endif() install(TARGETS portable_lib diff --git a/build/packaging/post_build_script.sh b/build/packaging/post_build_script.sh index fd71b18565..2e5c50c382 100644 --- a/build/packaging/post_build_script.sh +++ b/build/packaging/post_build_script.sh @@ -7,4 +7,5 @@ set -eux +rm -rf pip-out/ echo "This script is run after building ExecuTorch binaries" diff --git a/setup.py b/setup.py index d71133b7bd..9ff0d9b1ca 100644 --- a/setup.py +++ b/setup.py @@ -573,6 +573,15 @@ def get_ext_modules() -> List[Extension]: "executorch/examples/models/llama2/custom_ops", ) ) + ext_modules.append( + # Install the prebuilt library for quantized ops required by custom ops. + BuiltFile( + "kernels/quantized/libquantized_ops_aot_lib.*", + # Pushing the quantized ops to the same directory as the custom ops + # so that we don't need additional rpath for custom_ops. + "executorch/examples/models/llama2/custom_ops", + ) + ) # Note that setuptools uses the presence of ext_modules as the main signal # that a wheel is platform-specific. If we install any platform-specific