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

hardtanh to relu6

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