Automatic Differentiation for indexed data #516
Replies: 2 comments 3 replies
-
|
I mean, should I write two or more functions for my case? One part is for indexing data, and the other part is for computation. |
Beta Was this translation helpful? Give feedback.
-
|
You can only get gradients on Yes, you can write two functions and separate indexing and computation. Although feasible, writing two functions may have some negative performance impact: The indexed value must be saved back to slow memory (global memory for GPU) to be passed between functions. One possible way to work around this problem is to first derive the computing function, and inline it to the indexing function via |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Recently I built the forward pass for my custom function, but when I faced the backward pass, some problems happened.
For example, I have the embedding data$e$ and the indices $a$ and $b$ , the function is e[a] * e[b] (not real, for example). The gradient I want to obtain is the $e[a].grad$ and $e[b].grad$ , but the user guide didn't mention this situation. It only provides the backward creation for the given data (not indexing data).
Is there any suggestion or guide for my question? Thank you so much!
Beta Was this translation helpful? Give feedback.
All reactions