Skip to content

Commit 1d6ae76

Browse files
authored
Fix AxisAnalysis to avoid out of bound access. (#3832)
Resolves issue #3830. --------- Signed-off-by: Tiotto, Ettore <[email protected]>
1 parent 9fe51c3 commit 1d6ae76

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

third_party/intel/lib/Analysis/AxisInfo.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,13 @@ unsigned ModuleAxisInfoAnalysis::getAlignment(Value value) {
12361236
auto linAttr =
12371237
gpu::toLinearEncoding(tensorTy.getEncoding(), tensorTy.getShape());
12381238
auto order = linAttr.getOrder();
1239+
1240+
// FIXME: should this be an assertion instead?
1241+
// Temporarily added to avoid crashing on some tests.
1242+
// See issue #3842.
1243+
if (order[0] >= axisInfo->getRank())
1244+
return 1;
1245+
12391246
auto maxMultipleBytes = axisInfo->getDivisibility(order[0]);
12401247
auto maxContig = axisInfo->getContiguity(order[0]);
12411248

@@ -1270,7 +1277,14 @@ unsigned ModuleAxisInfoAnalysis::getMaskAlignment(Value mask) {
12701277
return 1;
12711278
auto linAttr =
12721279
gpu::toLinearEncoding(tensorTy.getEncoding(), tensorTy.getShape());
1280+
1281+
// FIXME: should this be an assertion instead?
1282+
// Temporarily added to avoid crashing on some tests.
1283+
// See issue #3842.
12731284
auto maskOrder = linAttr.getOrder();
1285+
if (maskOrder[0] >= axisInfo->getRank())
1286+
return 1;
1287+
12741288
auto alignment = std::max<unsigned>(axisInfo->getConstancy(maskOrder[0]), 1);
12751289
LDBG("getMaskAlignment maskOrder[0] " << maskOrder[0] << " alignment "
12761290
<< alignment);

0 commit comments

Comments
 (0)