Add TGATHER indices part - #988
Open
frank-deng wants to merge 3 commits into
Open
Conversation
Zhendong404
requested changes
Jul 25, 2026
| def gather_dtype_signatures(dtypes=NUMERIC_DTYPES): | ||
| res = [] | ||
| for dtype in dtypes: | ||
| for dtype_indices in ('i16', 'ui16', "f16", "bf16", "i32", "ui32", 'f32'): |
Collaborator
There was a problem hiding this comment.
tgather的verifier只支持整形,是否要支持浮点类型需要确认下
| @@ -3692,21 +3694,31 @@ struct PTOViewToMemrefPass | |||
|
|
|||
| if (indices || tmp) { | |||
| auto indicesTy = dyn_cast<MemRefType>(indices.getType()); | |||
Collaborator
There was a problem hiding this comment.
这里应该先判断indices是否存在,否则tmp存在而indices不存在的情况编译器会crash
| } | ||
| } | ||
|
|
||
| // CHECK: TGATHER |
Collaborator
There was a problem hiding this comment.
lit只check TGATHER op name,没有check tmp参数等是否符合预期
| @@ -0,0 +1,14 @@ | |||
| // RUN: ptoas --pto-arch=a5 %s 2>&1 | FileCheck %s | |||
|
|
|||
| module { | |||
Collaborator
There was a problem hiding this comment.
本PR的主要变更是把tmp变为可选参数,这里要有相应的正负例测试
Comment on lines
+47
to
+67
| if pto.const_expr(elem_bytes == 2 and elem_bytes_s1 == 4): | ||
| indices_type = pto.ui32 | ||
| lanes = pto.elements_per_vreg(indices_type) | ||
| for row in range(0, valid_rows, 1): | ||
| remained = valid_cols | ||
| for col in range(0, valid_cols, lanes): | ||
| indices_reg = pto.vlds(indices[row, col:]) | ||
| mask, remained = pto.make_mask(indices_type, remained) | ||
| dst_reg = pto.vgather2_bc(src_ptr, pto.vbitcast(indices_reg, indices_type), mask) | ||
| pto.vsts(dst_reg, dst[row, col:], mask) | ||
| elif pto.const_expr(elem_bytes == 1): | ||
| packed_lanes = pto.elements_per_vreg(dtype) >> 1 | ||
| result_elem = pto.ui16 if str(dtype) in ("ui8",) else pto.i16 | ||
| result_ty = pto.vreg_type(packed_lanes, result_elem) | ||
| for row in range(0, valid_rows, 1): | ||
| remained = valid_cols | ||
| for col in range(0, valid_cols, packed_lanes): | ||
| indices_reg = pto.vlds(indices[row, col:]) | ||
| mask, remained = pto.make_mask(result_elem, remained) | ||
| dst_reg = pto.vgather2(src_ptr, pto.vbitcast(indices_reg, pto.ui16), mask, result_vreg_type=result_ty) | ||
| pto.vsts(dst_reg, dst[row, col:], mask, dist=pto.VStoreDist.PK_B16) |
Collaborator
There was a problem hiding this comment.
这里4个分支大部分逻辑是相同的,能否合并,降低维护难度
| pto.vsts(dst_reg, dst[row, col:], mask) | ||
| elif pto.const_expr(elem_bytes == 1): | ||
| packed_lanes = pto.elements_per_vreg(dtype) >> 1 | ||
| result_elem = pto.ui16 if str(dtype) in ("ui8",) else pto.i16 |
Collaborator
There was a problem hiding this comment.
感觉用str(dtype)判断类型不太好,不能直接用dtype == pto.ui8判断吗?
| | `cdst` | `Optional<pto.tile_buf>` | Secondary destination tile used only by compare form | | ||
| | `indices` | `Optional<pto.tile_buf>` | Index tile used only by index form | | ||
| | `tmp` | `Optional<pto.tile_buf>` | Temporary tile used by index form and compare form | | ||
| | `tmp` | `Optional<pto.tile_buf>` | Temporary tile used by compare form; optionally used by index form on A2/A3 (required), A5 (optional) | |
| | `cdst` | `Optional<pto.tile_buf>` | Secondary destination tile used only by compare form | | ||
| | `indices` | `Optional<pto.tile_buf>` | Index tile used only by index form | | ||
| | `tmp` | `Optional<pto.tile_buf>` | Temporary tile used by index form and compare form | | ||
| | `tmp` | `Optional<pto.tile_buf>` | Temporary tile used by compare form; optionally used by index form on A2/A3 (required), A5 (optional) | |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.