You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2023/01/10 21:50:40 UTC
[GitHub] [tvm] masahi commented on a diff in pull request #13745: [Tensorize][TOPI] Add AMX Tensorizing for int8 batch matmul
masahi commented on code in PR #13745:
URL: https://github.com/apache/tvm/pull/13745#discussion_r1066380445
##########
tests/python/relay/test_op_level10.py:
##########
@@ -520,6 +520,58 @@ def test_batch_matmul_vnni(b, m, n, k):
np.testing.assert_equal(out, ref)
+@pytest.mark.skip("skip due to AMX feature not avaliable yet")
+@pytest.mark.parametrize(
+ "b,m,n,k",
+ [
+ (16, 32, 32, 128),
+ (16, 32, 32, 127),
+ (16, 32, 31, 128),
+ ],
+)
+def test_batch_matmul_amx(b, m, n, k):
+ amx_init = tvm.get_global_func("runtime.amx_init")
+ amx_tileconfig = tvm.get_global_func("runtime.amx_tileconfig")
+ assert amx_init()
+ assert amx_tileconfig(16, 64) # config tile size to 16 rows by 64 columns.
+
+ x_shape = (b, m, k)
+ y_shape = (b, n, k)
+ z_shape = (b, m, n)
+
+ for lhs_dtype in ["uint8", "int8"]:
+ x = relay.var("x", shape=x_shape, dtype=lhs_dtype)
+ y = relay.var("y", shape=y_shape, dtype="int8")
+ z = relay.var("z", shape=z_shape, dtype="int32")
+ bmm = relay.nn.batch_matmul(x, y, out_dtype="int32")
+ out = bmm + z
+ mod = tvm.IRModule.from_expr(out)
+
+ target = "llvm -mcpu=sapphirerapids"
+ with tvm.transform.PassContext(opt_level=3):
+ lib = relay.build(mod, target=target)
+
+ asm = lib.lib.get_source("asm")
+ assert "vpdpbusd" in asm
Review Comment:
This looks like a VNNI intrin
##########
python/tvm/topi/x86/batch_matmul.py:
##########
@@ -202,14 +229,19 @@ def _callback(op):
@autotvm.register_topi_schedule("batch_matmul_vnni.x86")
-def schedule_batch_matmul_vnni(cfg, outs):
+def schedule_batch_matmul_int8(cfg, outs):
"""Schedule for batch_matmul_vnni"""
s = te.create_schedule([x.op for x in outs])
+ mcpu = tvm.target.Target.current().mcpu
def _callback(op):
- if "batch_matmul_vnni" in op.tag:
+ if "batch_matmul_int8" in op.tag:
layout_trans = op.input_tensors[1]
- batch_matmul_vnni_schedule(cfg, s, op.output(0), outs[0], layout_trans)
+ print(layout_trans)
Review Comment:
remove
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org