Skip to content

Commit 0455876

Browse files
authored
[Triton][IR] Requirett.make_range op to have positive size (#7093)
1 parent f5a5b0f commit 0455876

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

lib/Dialect/Triton/IR/Ops.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ OpFoldResult MakeRangeOp::fold(FoldAdaptor adaptor) {
368368
LogicalResult MakeRangeOp::verify() {
369369
int64_t start = getStartAttr().getInt();
370370
int64_t end = getEndAttr().getInt();
371-
if (start > end) {
372-
return this->emitOpError() << "start must be less than or equal to end";
371+
if (start >= end) {
372+
return this->emitOpError() << "start must be less than end";
373373
}
374374
auto ty = getType();
375375
if (ty.getShape().size() != 1) {

test/Triton/verify-make-range.mlir

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tt.func public @_2d_tensor() {
2222

2323
// -----
2424
tt.func public @bad_start_end() {
25-
// expected-error @+1 {{start must be less than or equal to end}}
25+
// expected-error @+1 {{start must be less than end}}
2626
%a = tt.make_range { start = 0 : i32, end = -16 : i32 } : tensor<16xi32>
2727
tt.return
2828
}
@@ -33,3 +33,11 @@ tt.func public @bad_num_elems() {
3333
%a = tt.make_range { start = 0 : i32, end = 32 : i32 } : tensor<16xi32>
3434
tt.return
3535
}
36+
37+
// -----
38+
39+
tt.func @same_start_end() {
40+
// expected-error @+1 {{'tt.make_range' op start must be less than end}}
41+
%0 = tt.make_range{end = 1 : i32, start = 1 : i32} : tensor<0xi32>
42+
tt.return
43+
}

0 commit comments

Comments
 (0)