提交 3bca4e88 编写于 作者: S SunAhong1993

hardtanh to relu6

上级 65077a9e
...@@ -2174,12 +2174,16 @@ def aten_hardtanh_(mapper, graph, node): ...@@ -2174,12 +2174,16 @@ def aten_hardtanh_(mapper, graph, node):
# 处理输入2,即%66 # 处理输入2,即%66
layer_attrs["max"] = mapper.attrs[inputs_name[2]] layer_attrs["max"] = mapper.attrs[inputs_name[2]]
graph.add_layer( if layer_attrs["min"] ==0 and layer_attrs["max"] == 6:
'paddle.nn.Hardtanh', graph.add_layer(
inputs=layer_inputs, "paddle.nn.ReLU6", inputs=layer_inputs, outputs=layer_outputs, scope_name=scope_name)
outputs=layer_outputs, else:
scope_name=scope_name, graph.add_layer(
**layer_attrs) 'paddle.nn.Hardtanh',
inputs=layer_inputs,
outputs=layer_outputs,
scope_name=scope_name,
**layer_attrs)
return current_inputs, current_outputs return current_inputs, current_outputs
......
...@@ -336,8 +336,23 @@ class HierarchicalTree(Tree): ...@@ -336,8 +336,23 @@ class HierarchicalTree(Tree):
else: else:
module_name = module._get_name() module_name = module._get_name()
if module_name in module_name2sub_layers: if module_name in module_name2sub_layers:
module_name2sub_layers[module_name].append(sub_layers) if len(sub_layers[list(sub_layers.keys())[-1]].outputs) != \
module_name2sub_identifiers[module_name].append(sub_identifiers) len(module_name2sub_layers[module_name][0][list(module_name2sub_layers[module_name][0].keys())[-1]].outputs):
while module_name in module_name2sub_layers:
module_name = module_name + "__tmp"
if module_name in module_name2sub_layers and \
len(sub_layers[list(sub_layers.keys())[-1]].outputs) == \
len(module_name2sub_layers[module_name][0][list(module_name2sub_layers[module_name][0].keys())[-1]].outputs):
break
if module_name not in module_name2sub_layers:
module_name2sub_layers[module_name] = [sub_layers]
module_name2sub_identifiers[module_name] = [sub_identifiers]
else:
module_name2sub_layers[module_name].append(sub_layers)
module_name2sub_identifiers[module_name].append(sub_identifiers)
else:
module_name2sub_layers[module_name].append(sub_layers)
module_name2sub_identifiers[module_name].append(sub_identifiers)
else: else:
module_name2sub_layers[module_name] = [sub_layers] module_name2sub_layers[module_name] = [sub_layers]
module_name2sub_identifiers[module_name] = [sub_identifiers] module_name2sub_identifiers[module_name] = [sub_identifiers]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册