Skip to content

Commit

Permalink
[BUGFIX] Treatment of non-variadic operands after variadic operands.
Browse files Browse the repository at this point in the history
- There was a confusion of the index of the variadic ODS operand (i) and the index of its first occurrences (idx).
- Added a test case which triggered an error before this fix.
  • Loading branch information
pdamme committed Apr 8, 2024
1 parent 92fbc7d commit f3bd4d1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiler/lowering/RewriteToCallKernelOpPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ namespace
}
else
// Non-variadic operand.
newOperands.push_back(op->getOperand(i));
newOperands.push_back(op->getOperand(idx));
}
}
else
Expand Down
1 change: 1 addition & 0 deletions test/api/cli/operations/OperationsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ MAKE_TEST_CASE("operator_minus", 1)
MAKE_TEST_CASE("operator_plus", 2)
MAKE_TEST_CASE("operator_slash", 1)
MAKE_TEST_CASE("operator_times", 1)
MAKE_TEST_CASE("order", 1)
MAKE_TEST_CASE("rbind", 1)
MAKE_TEST_CASE("recode", 3)
MAKE_TEST_CASE("replace", 1)
Expand Down
14 changes: 14 additions & 0 deletions test/api/cli/operations/order_1.daphne
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Order a matrix by three columns.

// This test case was added to test the correct treatment of
// the non-variadic last parameter (returnIdxs) after two
// longer variadic parameters (colIdxs, ascs). There used to
// be a bug that was only triggered when an unproblematic (res1)
// and a problematic (res2) use were combined in the same
// DaphneDSL script.

X = reshape(seq(1, 6, 1), 2, 3);
res1 = order(X, 0, 1, false, false, false);
res2 = order(X, 0, 1, 2, false, false, false, false);
print(res1);
print(res2);
6 changes: 6 additions & 0 deletions test/api/cli/operations/order_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DenseMatrix(2x3, int64_t)
4 5 6
1 2 3
DenseMatrix(2x3, int64_t)
4 5 6
1 2 3

0 comments on commit f3bd4d1

Please sign in to comment.