Skip to content

Commit a293ad3

Browse files
Fix getFinalValue() to be able to handle values that are loop induction variables (#4565)
Fixes issue #4556. --------- Signed-off-by: Tiotto, Ettore <[email protected]> Signed-off-by: Whitney Tsang <[email protected]> Co-authored-by: Whitney Tsang <[email protected]>
1 parent 134494d commit a293ad3

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: triton-opt %s -triton-intel-remove-masks | FileCheck %s
2+
3+
module {
4+
// COM: Regression test for issue #4556.
5+
// COM: Ensure test compiles without triggering an assertion.
6+
tt.func public @issue_4556(%arg0: tensor<16x1x1x!tt.ptr<f32>>) {
7+
// CHECK-LABEL: issue_4556
8+
%c0_i32 = arith.constant 0 : i32
9+
%c1_i32 = arith.constant 1 : i32
10+
%c196_i32 = arith.constant 196 : i32
11+
%cst_0 = arith.constant dense<0.000000e+00> : tensor<16x1x1xf32>
12+
%cst_196 = arith.constant dense<196> : tensor<1x1x1xi32>
13+
scf.for %iv = %c0_i32 to %c196_i32 step %c1_i32 : i32 {
14+
%0 = tt.splat %iv : i32 -> tensor<1x1x1xi32>
15+
%1 = arith.cmpi slt, %0, %cst_196 : tensor<1x1x1xi32>
16+
%mask = tt.broadcast %1 : tensor<1x1x1xi1> -> tensor<16x1x1xi1>
17+
%2 = tt.load %arg0, %mask, %cst_0 : tensor<16x1x1x!tt.ptr<f32>>
18+
scf.yield
19+
}
20+
tt.return
21+
}
22+
}

third_party/intel/lib/Utils/Utility.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ Value getFinalValue(Value value) {
147147
BlockArgument blockArg = cast<BlockArgument>(value);
148148
Operation *parentOp = blockArg.getOwner()->getParentOp();
149149
if (scf::ForOp forOp = dyn_cast<scf::ForOp>(parentOp)) {
150+
if (blockArg == forOp.getInductionVar())
151+
return value;
152+
150153
int numIVs = forOp.getNumInductionVars();
151154
int initArgIdx = blockArg.getArgNumber() - numIVs;
152155
auto initArgs = forOp.getInitArgs();

0 commit comments

Comments
 (0)