Skip to content

Commit

Permalink
[IR][Parser] Hidet IR grammar, parser and ir reconstructor (#354)
Browse files Browse the repository at this point in the history
Currently, all IR roundtrips correctly in the test suite, for all
passes. The text is identical except for the attention ir module, which
has trivial changes (eg. (0 == wj) -> (wj == 0), or (!false) -> true).

Also fixed inline let stmt pass, so that types of tensors do not change
midway.

We need to add a dependency on lark, as the parser it generates is not
correct (does not have the same behavior as the original).

---------

Co-authored-by: Allan Lin <allan.lin@centml.ai>
  • Loading branch information
Aalanli and Allan Lin authored Aug 31, 2023
1 parent 021b067 commit e6e08e0
Show file tree
Hide file tree
Showing 8 changed files with 1,778 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/hidet/ir/builders/func_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def finish_func(self):
self.attrs['label'] = self.label
if self.body is None:
self.body = self.finish()
if 'func_kind' not in self.attrs:
self.attrs['func_kind'] = self.kind
self.func = Function(
self.name, kind=self.kind, params=self.params, body=self.body, ret_type=self.ret_type, attrs=self.attrs
)
Expand Down
1 change: 1 addition & 0 deletions python/hidet/ir/primitives/cuda/cvta.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def register_cvta_instructions():
@script
def cvta(src: PointerType(VoidType())) -> u32:
attrs.func_name = func_name
attrs.func_kind = 'cuda_internal'
ret: u32 = 0
asm(
template="{.reg.u64 smem_ptr; cvta.to.shared.u64 smem_ptr, %1; cvt.u32.u64 %0, smem_ptr;}",
Expand Down
2 changes: 2 additions & 0 deletions python/hidet/ir/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
from .printer import IRPrinter, astext
from .simplifier import simplify, simplify_to_int
from .hasher import ExprHash

# from .ir_dumper import astext2, parse
Loading

0 comments on commit e6e08e0

Please sign in to comment.