|
41 | 41 | CONSUME_RETURN_CALLBACK_ATTR = "refbackend_consume_return_callback" |
42 | 42 | refback_cb_attr = CONSUME_RETURN_CALLBACK_ATTR |
43 | 43 |
|
| 44 | +_exec_engine_shared_libs = [] |
| 45 | + |
44 | 46 | if ASYNC_RUNTIME_LIB_PATH := os.getenv("ASYNC_RUNTIME_LIB_PATH"): |
45 | 47 | ASYNC_RUNTIME_LIB_PATH = Path(ASYNC_RUNTIME_LIB_PATH) |
46 | 48 | else: |
|
49 | 51 | / f"{shlib_prefix()}mlir_async_runtime.{shlib_ext()}" |
50 | 52 | ) |
51 | 53 |
|
| 54 | +if ASYNC_RUNTIME_LIB_PATH.exists(): |
| 55 | + _exec_engine_shared_libs.append(ASYNC_RUNTIME_LIB_PATH) |
| 56 | + |
52 | 57 | if C_RUNNER_UTILS_LIB_PATH := os.getenv("C_RUNNER_UTILS_LIB_PATH"): |
53 | 58 | C_RUNNER_UTILS_LIB_PATH = Path(C_RUNNER_UTILS_LIB_PATH) |
54 | 59 | else: |
|
57 | 62 | / f"{shlib_prefix()}mlir_c_runner_utils.{shlib_ext()}" |
58 | 63 | ) |
59 | 64 |
|
| 65 | +if C_RUNNER_UTILS_LIB_PATH.exists(): |
| 66 | + _exec_engine_shared_libs.append(C_RUNNER_UTILS_LIB_PATH) |
| 67 | + |
60 | 68 | if RUNNER_UTILS_LIB_PATH := os.getenv("RUNNER_UTILS_LIB_PATH"): |
61 | 69 | RUNNER_UTILS_LIB_PATH = Path(RUNNER_UTILS_LIB_PATH) |
62 | 70 | else: |
|
65 | 73 | / f"{shlib_prefix()}mlir_runner_utils.{shlib_ext()}" |
66 | 74 | ) |
67 | 75 |
|
| 76 | +if RUNNER_UTILS_LIB_PATH.exists(): |
| 77 | + _exec_engine_shared_libs.append(RUNNER_UTILS_LIB_PATH) |
| 78 | + |
| 79 | +if CUDA_RUNTIME_LIB_PATH := os.getenv("CUDA_RUNTIME_LIB_PATH"): |
| 80 | + CUDA_RUNTIME_LIB_PATH = Path(CUDA_RUNTIME_LIB_PATH) |
| 81 | +else: |
| 82 | + CUDA_RUNTIME_LIB_PATH = ( |
| 83 | + Path(_mlir_libs.__file__).parent |
| 84 | + / f"{shlib_prefix()}mlir_cuda_runtime.{shlib_ext()}" |
| 85 | + ) |
| 86 | + |
| 87 | +if CUDA_RUNTIME_LIB_PATH.exists(): |
| 88 | + _exec_engine_shared_libs.append(CUDA_RUNTIME_LIB_PATH) |
| 89 | + |
68 | 90 |
|
69 | 91 | def get_ctype_func(mlir_ret_types): |
70 | 92 | ctypes_arg = [None] |
@@ -202,14 +224,10 @@ def __init__( |
202 | 224 | shared_lib_paths=None, |
203 | 225 | ): |
204 | 226 | if shared_lib_paths is None: |
205 | | - shared_lib_paths = [] |
| 227 | + shared_lib_paths = set() |
206 | 228 | if platform.system() != "Windows": |
207 | | - shared_lib_paths += [ |
208 | | - ASYNC_RUNTIME_LIB_PATH, |
209 | | - C_RUNNER_UTILS_LIB_PATH, |
210 | | - RUNNER_UTILS_LIB_PATH, |
211 | | - ] |
212 | | - self.shared_lib_paths = shared_lib_paths |
| 229 | + shared_lib_paths |= set(_exec_engine_shared_libs) |
| 230 | + self.shared_lib_paths = list(shared_lib_paths) |
213 | 231 | self.return_func_types = None |
214 | 232 | self.return_func_name = None |
215 | 233 |
|
|
0 commit comments