Browse Source

!5977 [bug]fix cell copy and print bug

Merge pull request !5977 from vlne-v1/bug-cell-copy
tags/v1.0.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
5166fe832d
1 changed files with 13 additions and 0 deletions
  1. +13
    -0
      mindspore/nn/cell.py

+ 13
- 0
mindspore/nn/cell.py View File

@@ -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):
# `<class 'xxxxxxx'>`
@@ -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__ + '<'


Loading…
Cancel
Save