Open bprb opened 1 year ago
Thank you for bringing it to our attention!
This is unfortunately a tricky situation. Since we do want to allow regular TensorView
types for passing non-differentiable data, it would be confusing to throw errors/warnings when using TensorView
with a [Differentiable]
function.
As you suggested, for now, we'll add an example with .fwd()
to the documentation to make the interface clearer, i.e., .fwd()
computes both the regular output & its derivative
Hi Sai, thank you for the quick reply! I see, this is a valid thing to do. We'll just have to be careful then :) Thanks for taking the suggestion about the docs!
Hello!
By mistake, I added
[Differentiable]
to thesquare
sample but I didn't changeTensorView
toDiffTensorView
.The result was a
square.fwd()
that simply calculatessquare()
. I was wondering if there is ever a valid use case for doing this, and if not, if perhaps the compiler could catch this mistake? Because otherwise, if I pass a single input and single output, also by mistake, then there are no errors, but the result is definitely not the forward gradient :)In detail, this shader...
... compiles without error, but
fwd
is not the gradient:So in this python code,
forward
is the same as thesquared
numbers:Output:
Everything is fine with the correct signature in the shader...
... and called as ...
So I was wondering if this user error could be caught? Perhaps it's also useful to add a
fwd
example to the docs to make it very clear that, just likebwd
, it expects a pair?Thanks! bert
(Edit: rewrote for clarity)