Skip to content

Commit

Permalink
fix: index access issue in argmin and argmax complex (#3176)
Browse files Browse the repository at this point in the history
Co-authored-by: Ianna Osborne <[email protected]>
  • Loading branch information
ManasviGoyal and ianna authored Jul 19, 2024
1 parent a9e48eb commit 4d5d49a
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 12 deletions.
6 changes: 3 additions & 3 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_argmax_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ERROR awkward_reduce_argmax_complex(
for (int64_t i = 0; i < lenparents; i++) {
int64_t parent = parents[i];
if (toptr[parent] == -1 ||
(fromptr[i * 2] > fromptr[toptr[parent * 2]] ||
(fromptr[i * 2] == fromptr[toptr[parent * 2]] &&
fromptr[i * 2 + 1] > fromptr[toptr[parent * 2 + 1]]))) {
(fromptr[i * 2] > fromptr[toptr[parent] * 2] ||
(fromptr[i * 2] == fromptr[toptr[parent] * 2] &&
fromptr[i * 2 + 1] > fromptr[toptr[parent] * 2 + 1]))) {
toptr[parent] = i;
}
}
Expand Down
6 changes: 3 additions & 3 deletions awkward-cpp/src/cpu-kernels/awkward_reduce_argmin_complex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ ERROR awkward_reduce_argmin_complex(
for (int64_t i = 0; i < lenparents; i++) {
int64_t parent = parents[i];
if (toptr[parent] == -1 ||
(fromptr[i * 2] < fromptr[toptr[parent * 2]] ||
(fromptr[i * 2] == fromptr[toptr[parent * 2]] &&
fromptr[i * 2 + 1] < fromptr[toptr[parent * 2 + 1]]))) {
(fromptr[i * 2] < fromptr[toptr[parent] * 2] ||
(fromptr[i * 2] == fromptr[toptr[parent] * 2] &&
fromptr[i * 2 + 1] < fromptr[toptr[parent] * 2 + 1]))) {
toptr[parent] = i;
}
}
Expand Down
12 changes: 6 additions & 6 deletions kernel-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4038,9 +4038,9 @@ kernels:
toptr[k] = -1
for i in range(lenparents):
parent = parents[i]
if (toptr[parent] == -1 or (fromptr[i * 2] > fromptr[toptr[parent * 2]] or
(fromptr[i * 2] == fromptr[toptr[parent * 2]] and
fromptr[i * 2 + 1] > fromptr[toptr[parent * 2 + 1]]))):
if (toptr[parent] == -1 or (fromptr[i * 2] > fromptr[toptr[parent] * 2] or
(fromptr[i * 2] == fromptr[toptr[parent] * 2] and
fromptr[i * 2 + 1] > fromptr[toptr[parent] * 2 + 1]))):
toptr[parent] = i
automatic-tests: false

Expand Down Expand Up @@ -4150,9 +4150,9 @@ kernels:
toptr[k] = -1
for i in range(lenparents):
parent = parents[i]
if (toptr[parent] == -1 or (fromptr[i * 2] < fromptr[toptr[parent * 2]] or
(fromptr[i * 2] == fromptr[toptr[parent * 2]] and
fromptr[i * 2 + 1] < fromptr[toptr[parent * 2 + 1]]))):
if (toptr[parent] == -1 or (fromptr[i * 2] < fromptr[toptr[parent] * 2] or
(fromptr[i * 2] == fromptr[toptr[parent] * 2] and
fromptr[i * 2 + 1] < fromptr[toptr[parent] * 2 + 1]))):
toptr[parent] = i
automatic-tests: false

Expand Down
142 changes: 142 additions & 0 deletions kernel-test-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -23992,6 +23992,148 @@
}
]
},
{
"name": "awkward_reduce_argmin_complex",
"status": true,
"tests": [
{
"error": false,
"message": "",
"inputs": {
"fromptr": [],
"lenparents": 0,
"outlength": 0,
"parents": []
},
"outputs": {
"toptr": []
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [0, 0],
"lenparents": 1,
"outlength": 1,
"parents": [0]
},
"outputs": {
"toptr": [0]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [1, 0, 0, 1],
"lenparents": 2,
"outlength": 1,
"parents": [0, 0]
},
"outputs": {
"toptr": [1]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23],
"lenparents": 9,
"outlength": 6,
"parents": [0, 0, 0, 2, 2, 3, 4, 4, 5]
},
"outputs": {
"toptr": [0, -1, 3, 5, 6, 8]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1],
"lenparents": 6,
"outlength": 4,
"parents": [0, 0, 0, 2, 2, 3]
},
"outputs": {
"toptr": [2, -1, 4, 5]
}
}
]
},
{
"name": "awkward_reduce_argmax_complex",
"status": true,
"tests": [
{
"error": false,
"message": "",
"inputs": {
"fromptr": [],
"lenparents": 0,
"outlength": 0,
"parents": []
},
"outputs": {
"toptr": []
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [0, 0],
"lenparents": 1,
"outlength": 1,
"parents": [0]
},
"outputs": {
"toptr": [0]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [1, 0, 0, 1],
"lenparents": 2,
"outlength": 1,
"parents": [0, 0]
},
"outputs": {
"toptr": [0]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [2, 2, 3, 3, 5, 5, 7, 7, 11, 11, 13, 13, 17, 17, 19, 19, 23, 23],
"lenparents": 9,
"outlength": 6,
"parents": [0, 0, 0, 2, 2, 3, 4, 4, 5]
},
"outputs": {
"toptr": [2, -1, 4, 5, 7, 8]
}
},
{
"error": false,
"message": "",
"inputs": {
"fromptr": [1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1],
"lenparents": 6,
"outlength": 4,
"parents": [0, 0, 0, 2, 2, 3]
},
"outputs": {
"toptr": [0, -1, 3, 5]
}
}
]
},
{
"name": "awkward_reduce_max",
"status": true,
Expand Down

0 comments on commit 4d5d49a

Please sign in to comment.