When a differentiable value uses heap storage and is multiply-referenced, move(along: directions) will first copy, and then update, the storage, which is inefficient. It should instead create new storage initialized with the result.
If you think about the way this plays out for an Array of differentiable values, you'll see that the only choice the Array currently has is to invoke e.move(along: d), in-place, which causes each element with shared storage to be copied and then updated.
When a differentiable value uses heap storage and is multiply-referenced,
move(along: directions)
will first copy, and then update, the storage, which is inefficient. It should instead create new storage initialized with the result.If you think about the way this plays out for an
Array
of differentiable values, you'll see that the only choice theArray
currently has is to invokee.move(along: d)
, in-place, which causes each element with shared storage to be copied and then updated.