I am using Nx inside Livebooks for educational purposes (rather than running production code). Recently I observe many warnings of this kind:
13:21:31.619 [warning] EXLA has compiled #Function<93.124553489/1 in EXLA.Backend.slice/5> 10 times with the same input shapes. This typically means tensor values are being captured inside a closure passed to defn, jit, or value_and_grad. Each distinct captured value forces a full recompilation. Pass changing tensors as explicit function arguments instead.
As far as I understand the warning was introduced by #1715 and is meant to be helpful but in my case I am not sure what exactly causes it. It is especially difficult to debug since the warning is triggered only sometimes and even disappears after running the same Livebook cell again. This makes it hard to understand if any of my code changes caused or resolved the warning.
Here is an example of a Livebook in which almost all cells trigger the warning sometimes:
https://github.com/laszlokorte/elixir-nx-mnist-livebook/blob/main/handwriting.livemd
My guess is that its somehow triggered by my plotting library:
https://github.com/laszlokorte/kino_zoetrope/blob/main/lib/kino_zoetrope/tensor_stack.ex#L70-L82
But I do not feel the warning message pointing me into the correct direction to fix it, especially since I am not calling defn, jit, or value_and_grad on any of my code paths directly (not knowing about Nx internals).
I am using Nx inside Livebooks for educational purposes (rather than running production code). Recently I observe many warnings of this kind:
As far as I understand the warning was introduced by #1715 and is meant to be helpful but in my case I am not sure what exactly causes it. It is especially difficult to debug since the warning is triggered only sometimes and even disappears after running the same Livebook cell again. This makes it hard to understand if any of my code changes caused or resolved the warning.
Here is an example of a Livebook in which almost all cells trigger the warning sometimes:
https://github.com/laszlokorte/elixir-nx-mnist-livebook/blob/main/handwriting.livemd
My guess is that its somehow triggered by my plotting library:
https://github.com/laszlokorte/kino_zoetrope/blob/main/lib/kino_zoetrope/tensor_stack.ex#L70-L82
But I do not feel the warning message pointing me into the correct direction to fix it, especially since I am not calling
defn,jit, orvalue_and_gradon any of my code paths directly (not knowing about Nx internals).