# Zygote and StaticArrays

**URL:** <https://discourse.julialang.org/t/zygote-and-staticarrays/86176>\
**Category:** Performance\
**Tags:** zygote, staticarrays\
**Created:** [August 23, 2022, 7:29am UTC](https://discourse.julialang.org/t/zygote-and-staticarrays/86176 "2022-08-23T07:29:05Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [August 26, 2022, 12:10am UTC](https://discourse.julialang.org/t/zygote-and-staticarrays/86176/4 "2022-08-26T00:10:36Z")

</div>

In general, Zygote tends to “lose” StaticArray gradients because none of its internals are aware of them. That means something as pedestrian as `gradient(x -> x[1] + sum(x), SA[1,2,3])` could (and does) end up on an allocating path and returning a `SizedArray`. Have you considered alternate AD libraries like ReverseDiff?

---

_[View the full topic](https://discourse.julialang.org/t/zygote-and-staticarrays/86176)._
