forked from triton-lang/triton
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support VNNI pre-encoded input in AMX lowering. (#210)
Signed-off-by: Ilya Enkovich <[email protected]>
- Loading branch information
Showing
8 changed files
with
435 additions
and
75 deletions.
There are no files selected for viewing
137 changes: 88 additions & 49 deletions
137
python/tutorials/cpu-blocked-matmul-fp32.py → python/tutorials/cpu-blocked-matmul.py
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from .utils import vnni_decode | ||
|
||
__all__ = ["vnni_decode"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from triton import jit | ||
import triton.language as tl | ||
from triton.language.core import builtin | ||
|
||
|
||
@jit | ||
def _vnni_decode(arg0): | ||
tl.static_assert(len(arg0.shape) == 2) | ||
tmp = arg0.reshape((arg0.shape[0], arg0.shape[1] // 2, 2)) | ||
tmp1, tmp2 = tl.split(tmp) | ||
return tl.join(tmp1.T, tmp2.T).reshape((arg0.shape[1] // 2, arg0.shape[0] * 2)).T | ||
|
||
|
||
@builtin | ||
def vnni_decode(arg0, _builder=None, _generator=None): | ||
bitwidth = arg0.dtype.primitive_bitwidth | ||
if bitwidth > 16: | ||
raise ValueError("Expected 8-bit or 16-bit values for vnni_decode") | ||
decoded = _generator.call_JitFunction(_vnni_decode, (arg0, ), kwargs={}) | ||
if bitwidth == 8: | ||
decoded = _generator.call_JitFunction(_vnni_decode, (decoded, ), kwargs={}) | ||
return decoded |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters