Fix RoBERTa model import (fixes
Summary: Pull Request resolved:
@@ -122,8 +122,10 @@ def register_model_architecture(model_name, arch_name):
# automatically import any Python files in the models/ directory
-for file in os.listdir(os.path.dirname(__file__)):
- if not file.startswith('_'):
+models_dir = os.path.dirname(__file__)
+for file in os.listdir(models_dir):
+ path = os.path.join(models_dir, file)
+ if not file.startswith('_') and (file.endswith('.py') or os.path.isdir(path)):
model_name = file[:file.find('.py')] if file.endswith('.py') else file
module = importlib.import_module('fairseq.models.' + model_name)
