From f3bd4d1144997722448271587f7a091c2a36e091 Mon Sep 17 00:00:00 2001 From: Patrick Damme Date: Mon, 8 Apr 2024 22:49:25 +0200 Subject: [PATCH] [BUGFIX] Treatment of non-variadic operands after variadic operands. - 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. --- .../lowering/RewriteToCallKernelOpPass.cpp | 2 +- test/api/cli/operations/OperationsTest.cpp | 1 + test/api/cli/operations/order_1.daphne | 14 ++++++++++++++ test/api/cli/operations/order_1.txt | 6 ++++++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/api/cli/operations/order_1.daphne create mode 100644 test/api/cli/operations/order_1.txt diff --git a/src/compiler/lowering/RewriteToCallKernelOpPass.cpp b/src/compiler/lowering/RewriteToCallKernelOpPass.cpp index db06779d0..f4a48434d 100644 --- a/src/compiler/lowering/RewriteToCallKernelOpPass.cpp +++ b/src/compiler/lowering/RewriteToCallKernelOpPass.cpp @@ -268,7 +268,7 @@ namespace } else // Non-variadic operand. - newOperands.push_back(op->getOperand(i)); + newOperands.push_back(op->getOperand(idx)); } } else diff --git a/test/api/cli/operations/OperationsTest.cpp b/test/api/cli/operations/OperationsTest.cpp index 9e1c33127..474a061a7 100644 --- a/test/api/cli/operations/OperationsTest.cpp +++ b/test/api/cli/operations/OperationsTest.cpp @@ -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) diff --git a/test/api/cli/operations/order_1.daphne b/test/api/cli/operations/order_1.daphne new file mode 100644 index 000000000..d0a899664 --- /dev/null +++ b/test/api/cli/operations/order_1.daphne @@ -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); \ No newline at end of file diff --git a/test/api/cli/operations/order_1.txt b/test/api/cli/operations/order_1.txt new file mode 100644 index 000000000..f5a1ab9d5 --- /dev/null +++ b/test/api/cli/operations/order_1.txt @@ -0,0 +1,6 @@ +DenseMatrix(2x3, int64_t) +4 5 6 +1 2 3 +DenseMatrix(2x3, int64_t) +4 5 6 +1 2 3