You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In each scope in which arrays are consumed, the reverse AD pass makes a copy of each consumed array just before entering the scope. In the forward pass, the arrays are substituted with their respective copies so that the original arrays (with their original values) remain available to the reverse pass. [1]
While this works, it's inefficient. For example, consider
Instead, we can just save the individual updated element(s) and avoid copying an entire new array. The saved element(s) are then used to restore the array so that all intermediate variables can be reproduced.
This is very similar to the saving/restoring we already do for scatter, just instrumented to work across scopes instead of only within scopes; the main distinction is that the forward re-execution sweep in each new scope must be modified to appropriately restore values--a restore must be placed preceding any statements which preceded the corresponding save in the forward sweep.
[1] returnSweepCode is responsible for substituting the names of the copies back to the originals in the reverse pass. There was a technical reason for choosing the originals in the return pass (instead of the copies), and unfortunately I forget it.
The text was updated successfully, but these errors were encountered:
In each scope in which arrays are consumed, the reverse AD pass makes a copy of each consumed array just before entering the scope. In the forward pass, the arrays are substituted with their respective copies so that the original arrays (with their original values) remain available to the reverse pass. [1]
While this works, it's inefficient. For example, consider
After applying AD, we have
Instead, we can just save the individual updated element(s) and avoid copying an entire new array. The saved element(s) are then used to restore the array so that all intermediate variables can be reproduced.
This is very similar to the saving/restoring we already do for
scatter
, just instrumented to work across scopes instead of only within scopes; the main distinction is that the forward re-execution sweep in each new scope must be modified to appropriately restore values--a restore must be placed preceding any statements which preceded the corresponding save in the forward sweep.[1]
returnSweepCode
is responsible for substituting the names of the copies back to the originals in the reverse pass. There was a technical reason for choosing the originals in the return pass (instead of the copies), and unfortunately I forget it.The text was updated successfully, but these errors were encountered: