diff --git a/CHANGELOG.md b/CHANGELOG.md index d8480cf..044a773 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,24 +1,32 @@ # Changelog All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). + +This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), with the exception that v0.X updates include backwards-incompatible API changes. +From v1.0.0 and on, the project will adherence strictly to Semantic Versioning. ## [Unreleased] +## [0.8.1] +### Fixed +- Bug in `forward_stepping`. +- Bug in `clean_state`. + + ## [0.8.0] ### Fixed -- Bugs in `forward_step(s)` with `update_state=False` +- Bugs in `forward_step(s)` with `update_state=False`. ### Changed - `forward_steps` interface to always include `pad_end` argument. -- name of "interface.py" to "module.py". -- implementations of `forward_step(s)` to be consolidated in CoModule. +- Name of "interface.py" to "module.py". +- Implementations of `forward_step(s)` to be consolidated in CoModule. ### Removed -- `Padded` interface +- `Padded` interface. ## [0.7.0] diff --git a/continual/conv.py b/continual/conv.py index 36a5553..99547c7 100644 --- a/continual/conv.py +++ b/continual/conv.py @@ -121,9 +121,12 @@ def init_state( return state_buffer, state_index, stride_index def clean_state(self): - del self.state_buffer - del self.state_index - del self.stride_index + if hasattr(self, "state_buffer"): + del self.state_buffer + if hasattr(self, "state_index"): + del self.state_index + if hasattr(self, "stride_index"): + del self.stride_index def get_state(self): if ( diff --git a/continual/convert.py b/continual/convert.py index 40b876a..d91c505 100644 --- a/continual/convert.py +++ b/continual/convert.py @@ -59,14 +59,21 @@ def call(x: Tensor, pad_end=False, update_state=True) -> Tensor: return call - def clean_state(*args, **kwargs): + def dummy(*args, **kwargs): ... # pragma: no cover + @staticmethod + def build_from(mod): # pragma: no cover + return module.__class__() + module.forward = module.forward module.forward_steps = forward_steps(module.forward) module.forward_step = forward_step(module.forward) module.delay = 0 - module.clean_state = clean_state + module.get_state = dummy + module.set_state = dummy + module.clean_state = dummy + module.build_from = build_from return module diff --git a/continual/delay.py b/continual/delay.py index 2eaa9c6..5a2a3d4 100644 --- a/continual/delay.py +++ b/continual/delay.py @@ -44,8 +44,10 @@ def init_state( return state_buffer, state_index def clean_state(self): - del self.state_buffer - del self.state_index + if hasattr(self, "state_buffer"): + del self.state_buffer + if hasattr(self, "state_index"): + del self.state_index def get_state(self): if ( diff --git a/continual/pooling.py b/continual/pooling.py index 4b8d1a3..ee53fcc 100644 --- a/continual/pooling.py +++ b/continual/pooling.py @@ -158,9 +158,12 @@ def init_state( return state_buffer, state_index, stride_index def clean_state(self): - del self.state_buffer - del self.state_index - del self.stride_index + if hasattr(self, "state_buffer"): + del self.state_buffer + if hasattr(self, "state_index"): + del self.state_index + if hasattr(self, "stride_index"): + del self.stride_index def get_state(self): if ( diff --git a/setup.py b/setup.py index 376c9b5..3fb6aae 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def from_file(file_name: str = "requirements.txt", comment_char: str = "#"): setup( name="continual-inference", - version="0.8.0", + version="0.8.1", description="Building blocks for Continual Inference Networks in PyTorch", long_description=long_description(), long_description_content_type="text/markdown", diff --git a/tests/continual/test_conv.py b/tests/continual/test_conv.py index de39c3d..b826db5 100644 --- a/tests/continual/test_conv.py +++ b/tests/continual/test_conv.py @@ -454,6 +454,7 @@ def test_update_state_false(): padding_mode="zeros", ) coconv = co.Conv3d.build_from(conv) + coconv.clean_state() # Nothing should happen target = conv.forward(sample) diff --git a/tests/continual/test_delay.py b/tests/continual/test_delay.py index e1f0c12..119a820 100644 --- a/tests/continual/test_delay.py +++ b/tests/continual/test_delay.py @@ -9,6 +9,7 @@ def test_delay_3d(): sample = torch.normal(mean=torch.zeros(4 * 3 * 3)).reshape((1, 1, 4, 3, 3)) delay = Delay(delay=2, temporal_fill="zeros") + delay.clean_state() # Nothing should happen ones = torch.ones_like(sample[:, :, 0]) diff --git a/tests/continual/test_pool.py b/tests/continual/test_pool.py index f4db0cb..9446e95 100644 --- a/tests/continual/test_pool.py +++ b/tests/continual/test_pool.py @@ -40,6 +40,7 @@ def test_AvgPool1d_padded(): target = pool(sample) co_pool = AvgPool1d.build_from(pool) + co_pool.clean_state() # Nothing should happen # forward output2 = co_pool.forward(sample)