Skip to content

Commit

Permalink
add more opt position and bpe helper (facebookresearch#2550)
Browse files Browse the repository at this point in the history
  • Loading branch information
dexterju27 authored Apr 13, 2020
1 parent 0d9e16d commit d694b99
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions parlai/utils/pickle.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,22 @@ class Unpickler(pickle._Unpickler): # type: ignore
def find_class(self, module, name):
try:
return super().find_class(module, name)
except ModuleNotFoundError:
except (ModuleNotFoundError, AttributeError):
if module.startswith('apex.'):
# user doesn't have apex installed. We'll deal with this later.
return FakeAPEXClass
else:
if module == 'parlai.core.utils' and name == 'Opt':
if (
module == 'parlai.core.utils' or module == 'parlai.utils.misc'
) and name == 'Opt':
from parlai.core.opt import Opt

return Opt
if module == 'parlai.core.dict' and name == '_BPEHelper':
from parlai.utils.bpe import SubwordBPEHelper as _BPEHelper

return _BPEHelper

raise


Expand Down

0 comments on commit d694b99

Please sign in to comment.