From 63f32cf66727a9edd0cbc8d5f1e71195e503e1e4 Mon Sep 17 00:00:00 2001 From: Wei Luning Date: Thu, 10 Sep 2020 11:10:18 +0800 Subject: [PATCH] cell copy bug fix 2 --- mindspore/nn/cell.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mindspore/nn/cell.py b/mindspore/nn/cell.py index e30daab52..888aa08ac 100755 --- a/mindspore/nn/cell.py +++ b/mindspore/nn/cell.py @@ -103,6 +103,16 @@ class Cell(Cell_): def already_run(self): return self._already_run + def __getstate__(self): + base = Cell_.__getstate__(self) + return base, self.__dict__ + + def __setstate__(self, state): + base, dict_ = state + Cell_.__setstate__(self, base) + self.__dict__ = dict_ + self._attr_synced = False + @property def _cell_tag(self): # `` @@ -388,6 +398,9 @@ class Cell(Cell_): """ return '' + def __str__(self): + return self.__repr__() + def __repr__(self): extra_str = self.extend_repr() info_str = self.__class__.__name__ + '<' -- GitLab