Skip to content

Commit 2dead53

Browse files
committed
[SPEC] Fix spec compiler & triton init
1 parent d3b025b commit 2dead53

5 files changed

Lines changed: 27 additions & 11 deletions

File tree

python/triton/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
)
2020
from .runtime.jit import constexpr_function, jit
2121
from .runtime._async_compile import AsyncCompileMode, FutureKernel
22-
from .compiler import compile, CompilationError, max_shared_mem
22+
from .compiler import compile, CompilationError
2323
from .errors import TritonError
2424
from .runtime._allocation import set_allocator
2525

@@ -29,6 +29,10 @@
2929

3030
must_use_result = language.core.must_use_result
3131

32+
# flagtree backend specialization
33+
from triton.flagtree_spec import spec
34+
spec("triton_extend_globals", globals())
35+
3236
__all__ = [
3337
"AsyncCompileMode",
3438
"autotune",
@@ -44,7 +48,6 @@
4448
"JITFunction",
4549
"KernelInterface",
4650
"language",
47-
"max_shared_mem",
4851
"MockTensor",
4952
"must_use_result",
5053
"next_power_of_2",

python/triton/compiler/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# flagtree backend path specialization
22
from triton.flagtree_spec import spec_path
3-
43
spec_path(__path__)
54

6-
from .compiler import CompiledKernel, ASTSource, IRSource, compile, make_backend, LazyDict, get_cache_key, max_shared_mem
5+
from .compiler import CompiledKernel, ASTSource, IRSource, compile, make_backend, LazyDict, get_cache_key
76
from .errors import CompilationError
87

8+
# flagtree backend specialization
9+
from triton.flagtree_spec import spec
10+
spec("compiler_extend_globals", globals())
11+
912
__all__ = [
1013
"compile", "make_backend", "ASTSource", "IRSource", "CompiledKernel", "CompilationError", "LazyDict",
11-
"get_cache_key", "max_shared_mem"
14+
"get_cache_key"
1215
]

python/triton/language/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
"""isort:skip_file"""
22
# Import order is significant here.
33

4-
from triton.flagtree_spec import spec_path, spec
5-
64
# flagtree backend path specialization
5+
from triton.flagtree_spec import spec_path
76
spec_path(__path__)
87

9-
# flagtree backend specialization
10-
spec("language_extend_globals", globals())
11-
128
from . import math
139
from . import extra
1410
from ..backends import language_extensions as ext
@@ -145,6 +141,10 @@
145141
)
146142
from . import target_info
147143

144+
# flagtree backend specialization
145+
from triton.flagtree_spec import spec
146+
spec("language_extend_globals", globals())
147+
148148
__all__ = [
149149
"PropagateNan",
150150
"TRITON_MAX_TENSOR_NUMEL",
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
from ._filecheck import spec_get_stub_target
21
from ._utils import apply_with_path, _tuple_create
2+
from ._filecheck import spec_get_stub_target
3+
from .compiler import compiler_extend_globals
34
from .language import language_extend_globals
5+
6+
def triton_extend_globals(globals_dict):
7+
# NOTE: Must use absolute path import.
8+
from triton.compiler.compiler import max_shared_mem
9+
globals_dict["max_shared_mem"] = max_shared_mem
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def compiler_extend_globals(globals_dict):
2+
# NOTE: Must use absolute path import.
3+
from triton.compiler.compiler import max_shared_mem
4+
globals_dict["max_shared_mem"] = max_shared_mem

0 commit comments

Comments
 (0)