You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by tq...@apache.org on 2024/06/07 13:03:36 UTC
(tvm) branch main updated: [WebGPU] Translate `int8x4` into `u32` (#17071)
This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 2f800df89d [WebGPU] Translate `int8x4` into `u32` (#17071)
2f800df89d is described below
commit 2f800df89d9e4ba366a1285b4246f286680951a6
Author: Jiawei Shao <ji...@intel.com>
AuthorDate: Fri Jun 7 21:03:29 2024 +0800
[WebGPU] Translate `int8x4` into `u32` (#17071)
This patch translates an `int8x4` into a `u32` in WGSL shaders as
8-bit integers are not supported in WebGPU right now and the WGSL
built-in function `dot4I8Packed()` accepts `u32` as its inputs and
each of the `u32` value logically represents a 4-element 8-bit
integer vector.
issue: #16627
---
src/target/source/codegen_webgpu.cc | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/target/source/codegen_webgpu.cc b/src/target/source/codegen_webgpu.cc
index f62e0db7ff..a95f6e0fa0 100644
--- a/src/target/source/codegen_webgpu.cc
+++ b/src/target/source/codegen_webgpu.cc
@@ -298,6 +298,11 @@ void CodeGenWebGPU::PrintType(DataType t, std::ostream& os) { // NOLINT(*)
if (lanes != 1) {
ICHECK(lanes >= 2 && lanes <= 4) << "CodeGenWebGPU: only allows vector with lanes in {2, 3, 4}";
+ // Currently WebGPU doesn't support `i8` and an `int8x4` is represented as a `u32`.
+ if (t.is_int() && t.bits() == 8 && lanes == 4) {
+ os << "u32";
+ return;
+ }
os << "vec" << lanes << "<";
}