(state, path)
| 390 | |
| 391 | def save(self, path): |
| 392 | def _save(state, path): |
| 393 | if not state: |
| 394 | return |
| 395 | state = { |
| 396 | k: ( |
| 397 | to_numpy(v) |
| 398 | if isinstance(v, paddle.base.libpaddle.pir.Value) |
| 399 | else v |
| 400 | ) |
| 401 | for k, v in state.items() |
| 402 | } |
| 403 | with open(path, 'wb') as f: |
| 404 | pickle.dump(state, f) |
| 405 | |
| 406 | def get_tensor(var): |
| 407 | t = global_scope().find_var(var.name).get_tensor() |