Skip to content

Commit ffc77a5

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

6 files changed

Lines changed: 29 additions & 11 deletions

File tree

python/triton/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""isort:skip_file"""
22
__version__ = '3.6.0'
33

4+
from triton.flagtree_spec import spec
5+
46
# ---------------------------------------
57
# Note: import order is significant here.
68

@@ -19,7 +21,7 @@
1921
)
2022
from .runtime.jit import constexpr_function, jit
2123
from .runtime._async_compile import AsyncCompileMode, FutureKernel
22-
from .compiler import compile, CompilationError, max_shared_mem
24+
from .compiler import compile, CompilationError
2325
from .errors import TritonError
2426
from .runtime._allocation import set_allocator
2527

@@ -29,6 +31,9 @@
2931

3032
must_use_result = language.core.must_use_result
3133

34+
# flagtree backend specialization
35+
spec("triton_extend_globals", globals())
36+
3237
__all__ = [
3338
"AsyncCompileMode",
3439
"autotune",
@@ -44,7 +49,6 @@
4449
"JITFunction",
4550
"KernelInterface",
4651
"language",
47-
"max_shared_mem",
4852
"MockTensor",
4953
"must_use_result",
5054
"next_power_of_2",

python/triton/compiler/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# flagtree backend path specialization
2-
from triton.flagtree_spec import spec_path
1+
from triton.flagtree_spec import spec_path, spec
32

3+
# flagtree backend path specialization
44
spec_path(__path__)
55

6-
from .compiler import CompiledKernel, ASTSource, IRSource, compile, make_backend, LazyDict, get_cache_key, max_shared_mem
6+
from .compiler import CompiledKernel, ASTSource, IRSource, compile, make_backend, LazyDict, get_cache_key
77
from .errors import CompilationError
88

9+
# flagtree backend specialization
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
# flagtree backend path specialization
77
spec_path(__path__)
88

9-
# flagtree backend specialization
10-
spec("language_extend_globals", globals())
11-
129
from . import math
1310
from . import extra
1411
from ..backends import language_extensions as ext
@@ -145,6 +142,9 @@
145142
)
146143
from . import target_info
147144

145+
# flagtree backend specialization
146+
spec("language_extend_globals", globals())
147+
148148
__all__ = [
149149
"PropagateNan",
150150
"TRITON_MAX_TENSOR_NUMEL",
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
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+
7+
def triton_extend_globals(globals_dict):
8+
# NOTE: Must use absolute path import.
9+
from triton.compiler.compiler import max_shared_mem
10+
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

third_party/mthreads/backend/spec/triton/language/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ def language_extend_globals(globals_dict):
77
globals_dict["unsqueeze"] = unsqueeze
88
globals_dict["_experimental_descriptor_load"] = _experimental_descriptor_load
99
globals_dict["_experimental_descriptor_store"] = _experimental_descriptor_store
10-
globals_dict["to_tensor"] = to_tensor
10+
globals_dict["to_tensor"] = to_tensor

0 commit comments

Comments
 (0)