-
Notifications
You must be signed in to change notification settings - Fork 71
fix tfillpad #939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix tfillpad #939
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -74,12 +74,12 @@ def template_tfillpad_expand(src: pto.Tile, dst: pto.Tile): | |||||||||
| has_valid_expansion = (src_valid_cols < dst_valid_cols) or (src_valid_rows < dst_valid_rows) | ||||||||||
|
|
||||||||||
| # PadValue handling - dtype-specific | ||||||||||
| if pto.constexpr(dtype == pto.f32): | ||||||||||
| if pto.constexpr(dst.pad_value == pto.PadValue.ZERO): | ||||||||||
| if has_valid_expansion: | ||||||||||
| fill_scalar = pto.f32(_NEG1_F32) | ||||||||||
| else: | ||||||||||
| fill_scalar = pto.f32(0.0) | ||||||||||
| if pto.constexpr(dtype == pto.f32): | ||||||||||
| if pto.constexpr(dst.pad_value == pto.PadValue.ZERO): | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PTODSL中对应的语法是 |
||||||||||
| if has_valid_expansion: | ||||||||||
| fill_scalar = pto.f32(_NEG1_F32) | ||||||||||
| else: | ||||||||||
| fill_scalar = pto.f32(0.0) | ||||||||||
| elif pto.constexpr(dst.pad_value != pto.PadValue.NULL): | ||||||||||
| fill_scalar = dst.pad_value.eval() | ||||||||||
| else: | ||||||||||
|
|
@@ -131,15 +131,16 @@ def template_tfillpad_expand(src: pto.Tile, dst: pto.Tile): | |||||||||
| fill_scalar = pto.i8(0) | ||||||||||
|
|
||||||||||
| # Phase 1: Copy aligned valid blocks | ||||||||||
| for row in range(0, src_valid_rows, 1): | ||||||||||
| remained = aligned_col | ||||||||||
| for col in range(0, aligned_col, lanes): | ||||||||||
| mask, remained = pto.make_mask(dtype, remained) | ||||||||||
| data = pto.vlds(src[row, col:]) | ||||||||||
| pto.vsts(data, dst[row, col:], mask) | ||||||||||
| if aligned_col > 0: | ||||||||||
| for row in range(0, src_valid_rows, 1): | ||||||||||
| remained = aligned_col | ||||||||||
| for col in range(0, aligned_col, lanes): | ||||||||||
| mask, remained = pto.make_mask(dtype, remained) | ||||||||||
| data = pto.vlds(src[row, col:]) | ||||||||||
| pto.vsts(data, dst[row, col:], mask) | ||||||||||
|
|
||||||||||
| # Phase 2: Fill col padding | ||||||||||
| if aligned_col < dst_valid_cols: | ||||||||||
| if aligned_col < dst_valid_cols: | ||||||||||
| for row in range(0, dst_valid_rows, 1): | ||||||||||
|
Comment on lines
+143
to
144
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High Severity Correctness IssueIssue: Potential uninitialized memory/garbage values in the destination tile when Explanation: However:
As a result, for any row in Suggested Fix:
# Phase 4: Fill row expansion
if pto.constexpr(src_valid_rows < dst_rows):
for row in range(src_valid_rows, dst_rows, 1):
remained = dst_valid_cols
for col in range(0, dst_valid_cols, lanes):
mask, remained = pto.make_mask(dtype, remained)
vec = pto.vdup(fill_scalar, mask)
pto.vsts(vec, dst[row, col:], mask)
Suggested change
|
||||||||||
| remained = dst_valid_cols - aligned_col | ||||||||||
| for col in range(aligned_col, dst_valid_cols, lanes): | ||||||||||
|
|
@@ -148,7 +149,7 @@ def template_tfillpad_expand(src: pto.Tile, dst: pto.Tile): | |||||||||
| pto.vsts(vec, dst[row, col:], mask) | ||||||||||
|
|
||||||||||
| # Phase 3: Copy tail valid lanes | ||||||||||
| if has_tail: | ||||||||||
| if has_tail: | ||||||||||
| for row in range(0, src_valid_rows, 1): | ||||||||||
| remained = src_valid_cols - aligned_col | ||||||||||
| mask_copy, remained = pto.make_mask(dtype, remained) | ||||||||||
|
|
@@ -164,4 +165,4 @@ def template_tfillpad_expand(src: pto.Tile, dst: pto.Tile): | |||||||||
| vec = pto.vdup(fill_scalar, mask) | ||||||||||
| pto.vsts(vec, dst[row, col:], mask) | ||||||||||
|
|
||||||||||
| return | ||||||||||
| return | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,12 +80,12 @@ def template_tfillpad(src: pto.Tile, dst: pto.Tile): | |
| has_valid_expansion = (src_valid_cols < dst_valid_cols) or (src_valid_rows < dst_valid_rows) | ||
|
|
||
| # PadValue handling - dtype-specific (inline to avoid external call) | ||
| if pto.constexpr(dtype == pto.f32): | ||
| if pto.constexpr(dst.pad_value == pto.PadValue.ZERO): | ||
| if has_valid_expansion: | ||
| fill_scalar = pto.f32(_NEG1_F32) | ||
| else: | ||
| fill_scalar = pto.f32(0.0) | ||
| if pto.constexpr(dtype == pto.f32): | ||
| if pto.constexpr(dst.pad_value == pto.PadValue.ZERO): | ||
| if has_valid_expansion: | ||
| fill_scalar = pto.f32(_NEG1_F32) | ||
| else: | ||
| fill_scalar = pto.f32(0.0) | ||
| elif pto.constexpr(dst.pad_value != pto.PadValue.NULL): | ||
| fill_scalar = dst.pad_value.eval() | ||
| else: | ||
|
|
@@ -137,15 +137,16 @@ def template_tfillpad(src: pto.Tile, dst: pto.Tile): | |
| fill_scalar = pto.i8(0) | ||
|
|
||
| # Phase 1: Copy aligned valid blocks | ||
| for row in range(0, src_valid_rows, 1): | ||
| remained = aligned_col | ||
| for col in range(0, aligned_col, lanes): | ||
| mask, remained = pto.make_mask(dtype, remained) | ||
| data = pto.vlds(src[row, col:]) | ||
| pto.vsts(data, dst[row, col:], mask) | ||
| if aligned_col > 0: | ||
| for row in range(0, src_valid_rows, 1): | ||
| remained = aligned_col | ||
| for col in range(0, aligned_col, lanes): | ||
| mask, remained = pto.make_mask(dtype, remained) | ||
| data = pto.vlds(src[row, col:]) | ||
| pto.vsts(data, dst[row, col:], mask) | ||
|
|
||
| # Phase 2: Fill cols from aligned_col to dst_cols-1 | ||
| if aligned_col < dst_cols: | ||
| if aligned_col < dst_cols: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. High Severity Correctness IssueIssue: Potential uninitialized memory/garbage values in the destination tile when Explanation: However:
As a result, any rows from Suggested Fix: # Phase 4: Fill row expansion
if pto.constexpr(src_valid_rows < dst_rows):
for row in range(src_valid_rows, dst_rows, 1):
remained = dst_cols
for col in range(0, dst_cols, lanes):
mask, remained = pto.make_mask(dtype, remained)
vec = pto.vdup(fill_scalar, mask)
pto.vsts(vec, dst[row, col:], mask) |
||
| for row in range(0, src_valid_rows, 1): | ||
| remained = dst_cols - aligned_col | ||
| for col in range(aligned_col, dst_cols, lanes): | ||
|
|
@@ -154,7 +155,7 @@ def template_tfillpad(src: pto.Tile, dst: pto.Tile): | |
| pto.vsts(vec, dst[row, col:], mask) | ||
|
|
||
| # Phase 3: Copy tail valid lanes | ||
| if has_tail: | ||
| if has_tail: | ||
| for row in range(0, src_valid_rows, 1): | ||
| remained = src_valid_cols - aligned_col | ||
| mask_copy, remained = pto.make_mask(dtype, remained) | ||
|
|
@@ -170,4 +171,4 @@ def template_tfillpad(src: pto.Tile, dst: pto.Tile): | |
| vec = pto.vdup(fill_scalar, mask) | ||
| pto.vsts(vec, dst[row, col:], mask) | ||
|
|
||
| return | ||
| return | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在TileLib已经切到PTODSL框架了,旧的TileLib不再使用,请直接更新到新的TileLib库:ptodsl/ptodsl/tilelib