From e8632b041ade3ba0f1c2b5ea9c2378118cd3e5d9 Mon Sep 17 00:00:00 2001 From: Unal Ege Gaznepoglu Date: Thu, 24 Oct 2024 12:48:42 +0200 Subject: [PATCH] Add a comment regarding reference cycles --- tensordict/_td.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensordict/_td.py b/tensordict/_td.py index 6a6b2040f..2785b7da4 100644 --- a/tensordict/_td.py +++ b/tensordict/_td.py @@ -978,6 +978,8 @@ def _cast_reduction( agglomerate, keepdim=keepdim, dim=dim ) + # IMPORTANT: do not directly access batch_dims (or any other property) + # via self.batch_dims otherwise a reference cycle is introduced def proc_dim(dim, batch_dims, tuple_ok=True): if dim is None: return dim