You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having trouble with understanding why the order of values in a tuple can affect the output of a function.
The following is a (possibly very suboptimal) implementation of reverse argsort in Halide, where the order of (value, index) or (index, value) in the output causes the result to change.
Note that by looking at the generated code, it makes sense that the order matters, because the tuple_select is effectively evaluated as two subsequent select statements:
Is this expected? Or is there maybe some way of requiring some kind of "atomic" update of the tuple that I am missing? I tried calling both sorted_value_and_index.update(1).atomic(False) and sorted_value_and_index.update(1).atomic(True), but that does not affect the output.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am having trouble with understanding why the order of values in a tuple can affect the output of a function.
The following is a (possibly very suboptimal) implementation of reverse argsort in Halide, where the order of (value, index) or (index, value) in the output causes the result to change.
Starting with some values:
Argsort can be implemented as follows:
However, the resulting output shows -1 for the indices:
On the other hand, if the order in the tuple is swapped:
The indices and values become correct:
Note that by looking at the generated code, it makes sense that the order matters, because the tuple_select is effectively evaluated as two subsequent select statements:
Is this expected? Or is there maybe some way of requiring some kind of "atomic" update of the tuple that I am missing? I tried calling both
sorted_value_and_index.update(1).atomic(False)
andsorted_value_and_index.update(1).atomic(True)
, but that does not affect the output.Beta Was this translation helpful? Give feedback.
All reactions