# Does TensorOperations.jl not support Zygote.jl?

**URL:** <https://discourse.julialang.org/t/does-tensoroperations-jl-not-support-zygote-jl/89174>\
**Category:** General Usage\
**Tags:** zygote, tensoroperations\
**Created:** [October 24, 2022, 3:46am UTC](https://discourse.julialang.org/t/does-tensoroperations-jl-not-support-zygote-jl/89174 "2022-10-24T03:46:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![F-YF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/f-yf/32/17363_2.png) [@F-YF](https://discourse.julialang.org/u/F-YF)\
**Post date:** [October 24, 2022, 3:46am UTC](https://discourse.julialang.org/t/does-tensoroperations-jl-not-support-zygote-jl/89174/1 "2022-10-24T03:46:13Z")

</div>

```julia
julia> using Zygote

julia> using TensorOperations

julia> function f(x) 
        @tensor b[i,k] := x[i,j]*x[j,k]
        sum(b)
        end
f (generic function with 1 method)

julia> a=rand(10,10);

julia> gradient(f,a)
ERROR: Can't differentiate gc_preserve_end expression $(Expr(:gc_preserve_end, %77)).
You might want to check the Zygote limitations documentation.
https://fluxml.ai/Zygote.jl/latest/limitations

```

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [November 1, 2022, 3:11pm UTC](https://discourse.julialang.org/t/does-tensoroperations-jl-not-support-zygote-jl/89174/2 "2022-11-01T15:11:50Z")

</div>

This isn’t built-in, but the gradients are again tensor expressions which are fairly simple to derive. One version is wrapped up as [TensorRules.jl](https://github.com/ho-oto/TensorRules.jl) (maybe the story starts [here](https://github.com/mcabbott/TensorTrack.jl)…).
