Skip to content

Commit

Permalink
[torch-frontend] only link aggregateCAPI with version (#445)
Browse files Browse the repository at this point in the history
so that it could reduce total size of wheel.
  • Loading branch information
qingyunqu authored Sep 10, 2024
1 parent 918af71 commit 79397e8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions frontends/torch-frontend/torch-frontend/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ add_mlir_python_common_capi_library(TorchFrontendMLIRAggregateCAPI

target_link_options(TorchFrontendMLIRAggregateCAPI PRIVATE $<$<PLATFORM_ID:Linux>:LINKER:--exclude-libs,ALL>)

# only link soversion TorchFrontendMLIRAggregateCAPI
get_target_property(LLVM_VERSION TorchFrontendMLIRAggregateCAPI VERSION)
set_target_properties(TorchFrontendMLIRAggregateCAPI PROPERTIES SOVERSION
${LLVM_VERSION})

add_mlir_python_modules(TorchFrontendPythonModules
ROOT_PREFIX "${TORCH_FRONTEND_BINARY_DIR}/python_packages/torch_frontend"
INSTALL_PREFIX "python_packages/torch_frontend"
Expand Down
3 changes: 2 additions & 1 deletion frontends/torch-frontend/torch-frontend/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def build_torch_frontend(self):
"python_packages",
"torch_frontend",
)
ignore_pattern = shutil.ignore_patterns("*TorchFrontendMLIRAggregateCAPI.so")
target_dir = os.path.join(self.build_lib, "torch_frontend")
if os.path.exists(target_dir):
shutil.rmtree(target_dir, ignore_errors=False, onerror=None)
shutil.copytree(python_package_dir, target_dir, symlinks=False)
shutil.copytree(python_package_dir, target_dir, symlinks=False, ignore=ignore_pattern)
shutil.copyfile(version_file, os.path.join(target_dir, "version.py"))

def build_torch_mlir(self):
Expand Down

0 comments on commit 79397e8

Please sign in to comment.