# Non-autodiff-computationally tractable gradients in forward pass

**URL:** <https://discuss.pytorch.org/t/non-autodiff-computationally-tractable-gradients-in-forward-pass/79661>\
**Category:** autograd\
**Created:** [May 4, 2020, 10:52am UTC](https://discuss.pytorch.org/t/non-autodiff-computationally-tractable-gradients-in-forward-pass/79661 "2020-05-04T10:52:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drezap](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/drezap/32/23721_2.png) [@drezap](https://discuss.pytorch.org/u/drezap)\
**Post date:** [May 4, 2020, 10:52am UTC](https://discuss.pytorch.org/t/non-autodiff-computationally-tractable-gradients-in-forward-pass/79661/1 "2020-05-04T10:52:18Z")

</div>

Hi -

Dumb question! May be I haven’t encountered it in the docs.

Suppose due to transformation and some bad functional form, I’m not able to build an expression graph in the forward pass. However, I’m able to do some analytic calculations and the gradient for the ill-formed loss function is tractable.

Is there a way to substitute `grad` or gradients WRT a loss function, with something I’ve implemented, for example, using finite differencing?

I’m sure my deep learning understanding is rather poor.

Thanks,

Andre

---

<div class="post-metadata">

**Author:** ![albanD](https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/alband/32/215_2.png) [@albanD](https://discuss.pytorch.org/u/albanD)\
**Post date:** [May 4, 2020, 3:11pm UTC](https://discuss.pytorch.org/t/non-autodiff-computationally-tractable-gradients-in-forward-pass/79661/2 "2020-05-04T15:11:31Z")

</div>

Hi,

You can check [this section](https://pytorch.org/docs/stable/notes/extending.html) of the doc that explains how to specify the backward formula for a forward that is not differentiable.
