Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clear
list
states (i.e. delete their contents), not reassign the de…
…fault `[]` (#2493) * Clear (i.e. delete) list state items, not simply overwrite. Previous behaviour produced memory leak from list[Tensor] states * Added test to check list states elements are deleted (even when referenced, and hence not automatically garbage collected). Fixed failing test (want to check list state, but assigned Tensor) * Updated documentation - highlighted reset clears list states, and that care must be taken when referencing them * Add missing method (sphinx) role * changelog * Remove failing testcode example (fixing introduces too much complexity) * Linting - Line break docstring * copy internal states in forward * Detach Tensor | list[Tensor] state values before copying. * Use 'typing' type hints * DO not clone (when caching) Tensor states, but retain references to avoid memory leakage * Revert "DO not clone (when caching) Tensor states, but retain references to avoid memory leakage" (This reverts commit ef27215.) * Added mypy type-hinting requirement/recommendation * Moved update from test checking .__init__ memory leakage. Added test checking .reset clears memory allocated during update (memory should be allowed to grow, as long as discarded safely) * Fix unused loop control variable for pre-commit --------- Co-authored-by: dominicgkerr <dominicgkerr1@gmail.co> Co-authored-by: Jirka Borovec <6035284+Borda@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Nicki Skafte Detlefsen <skaftenicki@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: stancld <daniel.stancl@gmail.com>
- Loading branch information