未验证 提交 fae896ef 编写于 作者: A Arash Bakhtiari 提交者: GitHub

Make OPT policy backward compatible with pre-OPT transformers versions (#2254)

上级 217338be
......@@ -444,13 +444,12 @@ class HFOPTLayerPolicy(DSPolicy):
try:
import transformers
HFOPTLayerPolicy._orig_layer_class = transformers.models.opt.modeling_opt.OPTDecoderLayer
if isinstance(DSPolicy.hf_model_config,
transformers.models.opt.configuration_opt.OPTConfig):
self.pre_attn_norm = self.hf_model_config.do_layer_norm_before
except:
HFOPTLayerPolicy._orig_layer_class = None
if isinstance(DSPolicy.hf_model_config,
transformers.models.opt.configuration_opt.OPTConfig):
self.pre_attn_norm = self.hf_model_config.do_layer_norm_before
def get_hidden_heads(self):
return self.client_module.self_attn.embed_dim, \
self.client_module.self_attn.num_heads
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册