Skip to content

Commit 7d8a249

Browse files
committed
Don't link to unnecessary MLIR runtime.
1 parent 108adbd commit 7d8a249

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

sparse/mlir_backend/_core.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
libc.free.argtypes = [ctypes.c_void_p]
1515
libc.free.restype = None
1616

17+
SHARED_LIBS = []
18+
if DEBUG:
19+
SHARED_LIBS.append(MLIR_C_RUNNER_UTILS)
20+
21+
OPT_LEVEL = 0 if DEBUG else 2
22+
1723
# TODO: remove global state
1824
ctx = Context()
1925

sparse/mlir_backend/_ops.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from ._array import Array
1111
from ._common import fn_cache
12-
from ._core import CWD, DEBUG, MLIR_C_RUNNER_UTILS, ctx, pm
12+
from ._core import CWD, DEBUG, OPT_LEVEL, SHARED_LIBS, ctx, pm
1313
from ._dtypes import DType, IeeeComplexFloatingDType, IeeeRealFloatingDType, IntegerDType
1414
from .levels import _determine_format
1515

@@ -79,7 +79,7 @@ def add(a, b):
7979
if DEBUG:
8080
(CWD / "add_module_opt.mlir").write_text(str(module))
8181

82-
return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
82+
return mlir.execution_engine.ExecutionEngine(module, opt_level=OPT_LEVEL, shared_libs=SHARED_LIBS)
8383

8484

8585
@fn_cache
@@ -104,7 +104,7 @@ def reshape(a, shape):
104104
if DEBUG:
105105
(CWD / "reshape_module_opt.mlir").write_text(str(module))
106106

107-
return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
107+
return mlir.execution_engine.ExecutionEngine(module, opt_level=OPT_LEVEL, shared_libs=SHARED_LIBS)
108108

109109

110110
@fn_cache
@@ -130,7 +130,7 @@ def broadcast_to(in_tensor):
130130
if DEBUG:
131131
(CWD / "broadcast_to_module_opt.mlir").write_text(str(module))
132132

133-
return mlir.execution_engine.ExecutionEngine(module, opt_level=2, shared_libs=[MLIR_C_RUNNER_UTILS])
133+
return mlir.execution_engine.ExecutionEngine(module, opt_level=OPT_LEVEL, shared_libs=SHARED_LIBS)
134134

135135

136136
def add(x1: Array, x2: Array) -> Array:

0 commit comments

Comments
 (0)