未验证 提交 5d30d072 编写于 作者: B Bai Yifan 提交者: GitHub

cherry-pick 30354 (#30407)

上级 c22ee575
...@@ -255,13 +255,19 @@ class ImperativeQuantAware(object): ...@@ -255,13 +255,19 @@ class ImperativeQuantAware(object):
if hasattr(layer, "skip_quant") and layer.skip_quant == True: if hasattr(layer, "skip_quant") and layer.skip_quant == True:
continue continue
scopes = name.split('.') last_idx = 0
target = scopes[-1] idx = 0
obj = model obj = model
parent = model parent = model
for i in range(len(scopes) - 1):
obj = getattr(parent, scopes[i]) while idx < len(name):
parent = obj if (name[idx] == '.'):
if hasattr(parent, name[last_idx:idx]):
obj = getattr(obj, name[last_idx:idx])
parent = obj
last_idx = idx + 1
idx += 1
target = name[last_idx:idx]
quant_layer = self._get_quantized_counterpart(layer) quant_layer = self._get_quantized_counterpart(layer)
setattr(quant_layer, "layer_name", layer.full_name()) setattr(quant_layer, "layer_name", layer.full_name())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册