# Zygote and TimerOutputs, derivative of timed function

**URL:** https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234
**Category:** Machine Learning
**Tags:** zygote
**Created:** [August 4, 2020, 5:41am UTC](https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234 "2020-08-04T05:41:00Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)
#### Post date: [August 4, 2020, 5:41am UTC](https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234/1 "2020-08-04T05:41:00Z")

</div>

Hi,  
sometimes I want to benchmark my code on my neural networks, especially their forward pass, using TimerOutputs.jl, but I don’t want to comment out all this when calculating gradients.  
Currently it’s crashing, not being able to derivate through the timing macro.  
Is there a way to define adjoint for this macro so the macro would effectively be ignored during backprop and just delegated gradient to the timed function?

Thanks.

---

<div class="post-metadata">

### Author: ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)
#### Post date: [November 7, 2021, 10:24pm UTC](https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234/2 "2021-11-07T22:24:14Z")

</div>

For future readers: this is exactly what [Zygote.ignore](https://fluxml.ai/Zygote.jl/latest/utils/#Zygote.ignore) was designed for.

---

<div class="post-metadata">

### Author: ![ToucheSir](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/touchesir/32/14411_2.png) [@ToucheSir](https://discourse.julialang.org/u/ToucheSir)
#### Post date: [March 4, 2022, 4:53pm UTC](https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234/3 "2022-03-04T16:53:40Z")

</div>

Since this got a bit of activity recently, [`ChainRulesCore.ignore_derivatives`](https://juliadiff.org/ChainRulesCore.jl/stable/api.html#ChainRulesCore.ignore_derivatives) is a better, lighter and AD-agnostic option now.

---

<div class="post-metadata">

### Author: ![racinmat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/racinmat/32/11715_2.png) [@racinmat](https://discourse.julialang.org/u/racinmat)
#### Post date: [March 7, 2022, 12:45pm UTC](https://discourse.julialang.org/t/zygote-and-timeroutputs-derivative-of-timed-function/44234/4 "2022-03-07T12:45:00Z")

</div>

Thanks, so the ignore\_derivatives is the AD agnostic version of Zygote.ignore and can be used in the same way? Good to know, thanks.
