# Zygote calculate adjoint only for one of several arguments

**URL:** https://discourse.julialang.org/t/zygote-calculate-adjoint-only-for-one-of-several-arguments/59606
**Category:** Specific Domains
**Tags:** zygote, ad
**Created:** [April 19, 2021, 7:12pm UTC](https://discourse.julialang.org/t/zygote-calculate-adjoint-only-for-one-of-several-arguments/59606 "2021-04-19T19:12:59Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [January 9, 2023, 3:02pm UTC](https://discourse.julialang.org/t/zygote-calculate-adjoint-only-for-one-of-several-arguments/59606/5 "2023-01-09T15:02:44Z")

</div>

> [@Tomas\_Pevny](#):
>
> I think it is not currently possible.

You can do it if you write a custom `rrule` for your function. Then you can return `@not_implemented("foo")` for the terms you don’t want.

Otherwise you are relying on the compiler to [eliminate “dead code”](https://en.wikipedia.org/wiki/Dead-code_elimination) for unused results.

In contrast, Enzyme.jl has separate explicit rules for constant arguments — see the post by @ChrisRackauckas contrasting Enzyme and Zygote rules: [What's the state of Automatic Differentiation in Julia January 2023? - #6 by ChrisRackauckas](https://discourse.julialang.org/t/whats-the-state-of-automatic-differentiation-in-julia-january-2023/92473/6)

---

_[View the full topic](https://discourse.julialang.org/t/zygote-calculate-adjoint-only-for-one-of-several-arguments/59606)._
