Is grad_fn for a non-differentiable function that function's inverse?

What is grad_fn for a non-differentiable function like grad_fn=<SliceBackward0>, grad_fn=<ViewBackward0>, etc.? Is it simply the function’s inverse operation?

Where in the source code can I see the implementation of SliceBackward0, ViewBackward0, etc.? I assume it’s in their backward() static methods somewhere.

Usually how they are implemented is materialize a full zeros tensor, replaying the view, and in-place copying the gradient output into that view. This effectively scatters the gradients into where they need to be.

You can find some impls in torch/csrc/autograd/FunctionsManual.cpp.