Skip to content

Commit

Permalink
use 'backend' instead of 'target'
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoly Myachev <anatoly.myachev@intel.com>
  • Loading branch information
anmyachev committed Nov 14, 2024
1 parent be08db0 commit a99f9f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
7 changes: 4 additions & 3 deletions python/test/unit/tools/test_irsource.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import tempfile
import triton
from triton.compiler import IRSource
from triton.compiler import IRSource, make_backend
from triton._C.libtriton import ir

target = triton.runtime.driver.active.get_current_target()
backend = make_backend(target)


def test_mlir_attribute_parsing() -> None:
Expand Down Expand Up @@ -41,7 +42,7 @@ def test_mlir_attribute_parsing() -> None:
f.write(sample_ttgir)
f.flush()
context = ir.context()
src = IRSource(f.name, context, target)
src = IRSource(f.name, context, backend)

# check name and type signature
# should match ty_to_cpp(...)
Expand Down Expand Up @@ -87,7 +88,7 @@ def test_mlir_attribute_parsing() -> None:
f.write(sample_ttgir_vector_add)
f.flush()
context = ir.context()
src = IRSource(f.name, context, target)
src = IRSource(f.name, context, backend)

# now test compilation
triton.compile(f.name, target=target)
8 changes: 2 additions & 6 deletions python/triton/compiler/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,12 @@ def parse_options(self):

class IRSource:

def __init__(self, path, context, target=None):
def __init__(self, path, context, backend):
self.path = path
path = Path(path)
self.ext = path.suffix[1:]
self.src = path.read_text()
ir.load_dialects(context)
if target is None:
target = driver.active.get_current_target()
assert isinstance(target, GPUTarget), "target must be of GPUTarget type"
backend = make_backend(target)
backend.load_dialects(context)

# We don't have a easy-to-use PTX parser that we can use, so keep that regex for now.
Expand Down Expand Up @@ -228,7 +224,7 @@ def compile(src, target=None, options=None):
if ir_source:
assert isinstance(src, str), "source must be either AST or a filepath"
context = ir.context()
src = IRSource(src, context, target)
src = IRSource(src, context, backend)

extra_options = src.parse_options()
options = backend.parse_options(dict(options or dict(), **extra_options))
Expand Down

0 comments on commit a99f9f0

Please sign in to comment.