Replies: 1 comment 3 replies
|
One way would be the following: let non_negs = a > 0;
let res = non_negs * (a - 1) + (1 - non_negs) * a;Indexing functions like lookup and eval macro can also be used I think but I believe the above version is better in terms of performance because there is no random lookup involved and all reads/writes to GPU memory are coalesced. |
3 replies
Answer selected by
3togo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One way would be the following:
Indexing functions like lookup and eval macro can also be used I think but I believe the above version is better in terms of performance because there is no random lookup involved and all reads/writes to GPU memory are coalesced.