Skip to content

Commit e0cb671

Browse files
Fix checkpoint of Light-NAS (#18332)
Socket can't be pickled. test=release/1.5
1 parent e517202 commit e0cb671

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

python/paddle/fluid/contrib/slim/nas/light_nas_strategy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ def on_compression_begin(self, context):
127127
self._search_agent = SearchAgent(
128128
self._server_ip, self._server_port, key=self._key)
129129

130+
def __getstate__(self):
131+
"""Socket can't be pickled."""
132+
d = {}
133+
for key in self.__dict__:
134+
if key not in ["_search_agent", "_server"]:
135+
d[key] = self.__dict__[key]
136+
return d
137+
130138
def _constrain_func(self, tokens, context=None):
131139
"""Check whether the tokens meet constraint."""
132140
_, _, test_prog, _, _, _, _ = context.search_space.create_net(tokens)

0 commit comments

Comments
 (0)