Skip to content

Commit

Permalink
(fix)(torch frontend)(module.py): extended the __getstate__ and __set…
Browse files Browse the repository at this point in the history
…state__ implementations for the frontend Module class to fix the pickling issue for keras models.
  • Loading branch information
YushaArif99 committed Jun 2, 2024
1 parent e36b7a9 commit a04a857
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ivy/functional/frontends/torch/nn/modules/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import ivy
from collections import OrderedDict
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple, Callable
import threading

# local
from ivy.functional.frontends.torch.nn.parameter import Parameter
Expand Down Expand Up @@ -368,7 +369,11 @@ def __dir__(self):
def __getstate__(self):
state = self.__dict__.copy()
state.pop("_compiled_call_impl", None)
state.pop("_thread_local", None)
state.pop("_metrics_lock", None)
return state

def __setstate__(self, state):
state["_thread_local"] = threading.local()
state["_metrics_lock"] = threading.Lock()
self.__dict__.update(state)

0 comments on commit a04a857

Please sign in to comment.