# How careful must I be doing setindex! on untracked arrays in ReverseDiff.jl?

**URL:** <https://discourse.julialang.org/t/how-careful-must-i-be-doing-setindex-on-untracked-arrays-in-reversediff-jl/4360>\
**Category:** General Usage\
**Tags:** question, package\
**Created:** [June 20, 2017, 6:22am UTC](https://discourse.julialang.org/t/how-careful-must-i-be-doing-setindex-on-untracked-arrays-in-reversediff-jl/4360 "2017-06-20T06:22:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcovalt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcovalt/32/1722_2.png) [@mcovalt](https://discourse.julialang.org/u/mcovalt)\
**Post date:** [June 20, 2017, 6:22am UTC](https://discourse.julialang.org/t/how-careful-must-i-be-doing-setindex-on-untracked-arrays-in-reversediff-jl/4360/1 "2017-06-20T06:22:43Z")

</div>

Comparing ReverseDiff.jl to a similar Python package ([autograd](https://github.com/HIPS/autograd/blob/master/docs/tutorial.md)), I see in their documentation:

> In-place modification of arrays not being differentiated with respect to (for example, `A[i] = x` or `A += B`) won’t raise an error, but be careful. It’s easy to accidentally change something without autograd knowing about it. This can be a problem because autograd keeps references to variables used in the forward pass if they will be needed on the reverse pass. Making copies would be too slow.

From what I think I’m reading, on the forward pass the package will track an operation from `A` applied to a tracked variable, but on the reverse pass it will only apply what it sees from `A` when reading its reference from memory. If untracked instructions modified `A`, these will not be reflected when differentiating.

Does this warning apply to ReverseDiff.jl as well? If so, am I correct in how I interpreted this warning?

---

<div class="post-metadata">

**Author:** ![dfdx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dfdx/32/120_2.png) [@dfdx](https://discourse.julialang.org/u/dfdx)\
**Post date:** [June 20, 2017, 8:38am UTC](https://discourse.julialang.org/t/how-careful-must-i-be-doing-setindex-on-untracked-arrays-in-reversediff-jl/4360/2 "2017-06-20T08:38:02Z")

</div>

As a side note, there’s also [AutoGrad.jl](https://github.com/denizyuret/AutoGrad.jl) which is likely to be closer to Python’s autograd. This doesn’t mean you should prefer one to another though.
