Jit'ing the grad function #1958
-
I have an inner function in my network where calling Is there a way to do this that I'm missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
(I am not sure if I fully understand your question, so please clarify if my answer below is not what you were asking.) Do you mean you are calling
The jitted function will be compiled only once for each shape it is called with, so if the shapes are the same in the loop then this is not bad. |
Beta Was this translation helpful? Give feedback.
(I am not sure if I fully understand your question, so please clarify if my answer below is not what you were asking.)
Do you mean you are calling
grad
inside your Module's apply function? If youjit
something inside anotherjit
block, then the innerjit
should be a no-op. We usuallyjit
the entire train function, which calls the grad function so that will be jitted inside this bigger block (we actually prefer jitting bigger blocks because it gives XLA more opportunity for optimizing things -- at the cost of longer compile time).The jitted function will be compiled only once for each shape it is…