From 0e9bbf408defc69925e10456d3bdcb3aa811a753 Mon Sep 17 00:00:00 2001 From: chMoussa Date: Thu, 29 Aug 2024 14:22:28 +0200 Subject: [PATCH] [BugFix] Avoid reduce with empty operations (#270) --- pyqtorch/composite/sequence.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyqtorch/composite/sequence.py b/pyqtorch/composite/sequence.py index 02bda51e..8e2c0233 100644 --- a/pyqtorch/composite/sequence.py +++ b/pyqtorch/composite/sequence.py @@ -94,7 +94,11 @@ def __len__(self) -> int: return len(self.operations) def __hash__(self) -> int: - return hash(reduce(add, (hash(op) for op in self.operations))) + return hash( + reduce(add, (hash(op) for op in self.operations)) + if len(self.operations) > 0 + else self.operations + ) def forward( self,