diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index ef1c4d457..49b2bd361 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -120,4 +120,5 @@ add_mlir_python_modules(GcPythonModules GcPythonCAPI ) +add_dependencies(GcPythonModules GcCpuRuntime) configure_file(config.py.in ${MLIR_BINARY_DIR}/python_packages/gc_mlir_core/gc_mlir/config.py @ONLY) diff --git a/python/config.py.in b/python/config.py.in index 2e4a2099e..963ac498c 100644 --- a/python/config.py.in +++ b/python/config.py.in @@ -4,6 +4,8 @@ import sys llvm_obj_root = "@LLVM_BINARY_DIR@" llvm_lib_dir = "@LLVM_LIBRARY_DIR@" shlib_ext = "@LTDL_SHLIB_EXT@" +gc_lib_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" + if sys.platform.startswith("win32"): mlir_runner_utils_dir = os.path.normpath(os.path.join(llvm_obj_root, "bin")) @@ -20,3 +22,7 @@ MLIR_C_RUNNER_UTILS = os.path.normpath( MLIR_RUNNER_UTILS = os.path.normpath( os.path.join(mlir_runner_utils_dir, shlib_prefix + "mlir_runner_utils" + shlib_ext) ) + +GC_CPU_RUNTIME = os.path.normpath( + os.path.join(gc_lib_dir, shlib_prefix + "GcCpuRuntime" + shlib_ext) +) \ No newline at end of file diff --git a/python/gc_mlir/graph_compiler.py b/python/gc_mlir/graph_compiler.py index c7c58804d..fd2966d19 100644 --- a/python/gc_mlir/graph_compiler.py +++ b/python/gc_mlir/graph_compiler.py @@ -6,10 +6,8 @@ # # ===-----------------------------------------------------------------------===# -from gc_mlir import execution_engine -from gc_mlir import ir -from gc_mlir import passmanager -from gc_mlir.config import MLIR_C_RUNNER_UTILS, MLIR_RUNNER_UTILS +from gc_mlir import execution_engine, ir, passmanager +from gc_mlir.config import GC_CPU_RUNTIME, MLIR_C_RUNNER_UTILS, MLIR_RUNNER_UTILS __all__ = [ "GraphCompiler", @@ -22,7 +20,7 @@ def __init__( pipeline: str = "any(gc-cpu-pipeline)", opt_level: int = 3, ): - self.shared_libs = [MLIR_C_RUNNER_UTILS, MLIR_RUNNER_UTILS] + self.shared_libs = [MLIR_C_RUNNER_UTILS, MLIR_RUNNER_UTILS, GC_CPU_RUNTIME] self.pipeline = pipeline self.opt_level = opt_level