Browse Source

!1027 fix the bug about cannot find some activation function op

From: @yelihua
Reviewed-by: @lilongfei15,@wenkai_dist,@lilongfei15
Signed-off-by: @lilongfei15
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
e4d675bfa9
6 changed files with 174 additions and 23 deletions
  1. +3
    -3
      mindinsight/debugger/conditionmgr/condition.py
  2. +16
    -15
      mindinsight/debugger/stream_cache/node_type_identifier.py
  3. +48
    -1
      tests/st/func/debugger/expect_results/restful_results/search_activation.json
  4. +104
    -1
      tests/st/func/debugger/expect_results/restful_results/search_activation_multi_graph.json
  5. +2
    -2
      tests/ut/debugger/stream_cache/test_node_type_identifier.py
  6. +1
    -1
      tests/ut/debugger/stream_handler/test_graph_handler.py

+ 3
- 3
mindinsight/debugger/conditionmgr/condition.py View File

@@ -107,9 +107,9 @@ class ParamTypeEnum(Enum):


class ActivationFuncEnum(Enum): class ActivationFuncEnum(Enum):
"""Activation functions.""" """Activation functions."""
TANH = 'Tanh'
SIGMOID = 'Sigmoid'
RELU = 'ReLU'
TANH = 'tanh'
SIGMOID = 'sigmoid'
RELU = 'relu'




class ConditionContext: class ConditionContext:


+ 16
- 15
mindinsight/debugger/stream_cache/node_type_identifier.py View File

@@ -19,20 +19,21 @@ from mindinsight.datavisual.data_transform.graph import NodeTypeEnum
from mindinsight.debugger.common.exceptions.exceptions import DebuggerParamValueError from mindinsight.debugger.common.exceptions.exceptions import DebuggerParamValueError


_ACTIVATIONS = [ _ACTIVATIONS = [
'ELU',
'FastGelu',
'GELU',
'HSigmoid',
'HSwish',
'LeakyReLU',
'LogSigmoid',
'LogSoftmax',
'PReLU',
'ReLU',
'ReLU6',
'Sigmoid',
'Softmax',
'Tanh'
'elu',
'fastgelu',
'gelu',
'hsigmoid',
'hswish',
'leakyrelu',
'logsigmoid',
'logsoftmax',
'prelu',
'relu',
'relu6',
'reluv2',
'sigmoid',
'softmax',
'tanh'
] ]




@@ -122,7 +123,7 @@ def is_activation_node(node, condition=None):
if not is_gradient_node(node): if not is_gradient_node(node):
node_type = node.type node_type = node.type
for activation_name in activation_funcs: for activation_name in activation_funcs:
if node_type == activation_name:
if node_type.lower() == activation_name:
return True return True
return False return False




+ 48
- 1
tests/st/func/debugger/expect_results/restful_results/search_activation.json View File

@@ -1 +1,48 @@
{"nodes": [{"name": "Default", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]}
{
"nodes": [
{
"name": "Default",
"type": "name_scope",
"nodes": [
{
"name": "Default/network-WithLossCell",
"type": "name_scope",
"nodes": [
{
"name": "Default/network-WithLossCell/_backbone-LeNet5",
"type": "name_scope",
"nodes": [
{
"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU",
"type": "name_scope",
"nodes": [
{
"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87",
"type": "ReLUV2",
"nodes": []
},
{
"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89",
"type": "ReLUV2",
"nodes": []
},
{
"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12",
"type": "ReLU",
"nodes": []
},
{
"name": "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15",
"type": "ReLU",
"nodes": []
}
]
}
]
}
]
}
]
}
]
}

+ 104
- 1
tests/st/func/debugger/expect_results/restful_results/search_activation_multi_graph.json View File

@@ -1 +1,104 @@
{"nodes": [{"name": "graph_0", "type": "name_scope", "nodes": [{"name": "graph_0/Default", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]}, {"name": "graph_1", "type": "name_scope", "nodes": [{"name": "graph_1/Default", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU", "type": "name_scope", "nodes": [{"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12", "type": "ReLU", "nodes": []}, {"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15", "type": "ReLU", "nodes": []}]}]}]}]}]}]}
{
"nodes": [
{
"name": "graph_0",
"type": "name_scope",
"nodes": [
{
"name": "graph_0/Default",
"type": "name_scope",
"nodes": [
{
"name": "graph_0/Default/network-WithLossCell",
"type": "name_scope",
"nodes": [
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5",
"type": "name_scope",
"nodes": [
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU",
"type": "name_scope",
"nodes": [
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87",
"type": "ReLUV2",
"nodes": []
},
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89",
"type": "ReLUV2",
"nodes": []
},
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12",
"type": "ReLU",
"nodes": []
},
{
"name": "graph_0/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15",
"type": "ReLU",
"nodes": []
}
]
}
]
}
]
}
]
}
]
},
{
"name": "graph_1",
"type": "name_scope",
"nodes": [
{
"name": "graph_1/Default",
"type": "name_scope",
"nodes": [
{
"name": "graph_1/Default/network-WithLossCell",
"type": "name_scope",
"nodes": [
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5",
"type": "name_scope",
"nodes": [
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU",
"type": "name_scope",
"nodes": [
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87",
"type": "ReLUV2",
"nodes": []
},
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89",
"type": "ReLUV2",
"nodes": []
},
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12",
"type": "ReLU",
"nodes": []
},
{
"name": "graph_1/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15",
"type": "ReLU",
"nodes": []
}
]
}
]
}
]
}
]
}
]
}
]
}

+ 2
- 2
tests/ut/debugger/stream_cache/test_node_type_identifier.py View File

@@ -60,8 +60,8 @@ class TestNodeTypeIdentifier:
('Default/mock/relu_ReLU-op11', "ReLU", None, True), ('Default/mock/relu_ReLU-op11', "ReLU", None, True),
('Gradients/mock/relu_ReLU-op11', "ReLU", None, False), ('Gradients/mock/relu_ReLU-op11', "ReLU", None, False),
('Default/mock/relu_ReLU-op11', "Parameter", None, False), ('Default/mock/relu_ReLU-op11', "Parameter", None, False),
('Default/mock/relu_ReLU-op11', "ReLU", {'activation_func': 'Softmax'}, False),
('Default/mock/relu_ReLU-op11', "Softmax", {'activation_func': ['ReLU', 'Softmax']}, True)
('Default/mock/relu_ReLU-op11', "ReLU", {'activation_func': 'softmax'}, False),
('Default/mock/relu_ReLU-op11', "Softmax", {'activation_func': ['relu', 'softmax']}, True)
]) ])
def test_activate_node(self, name, node_type, condition, result): def test_activate_node(self, name, node_type, condition, result):
"""Test activate node.""" """Test activate node."""


+ 1
- 1
tests/ut/debugger/stream_handler/test_graph_handler.py View File

@@ -73,7 +73,7 @@ class TestGraphHandler:


@pytest.mark.parametrize("node_type, condition, result_file", [ @pytest.mark.parametrize("node_type, condition, result_file", [
("weight", None, "search_nodes_by_type_0.json"), ("weight", None, "search_nodes_by_type_0.json"),
("activation", {'activation_func': ['ReLU', 'Softmax']}, "search_nodes_by_type_1.json")
("activation", {'activation_func': ['relu', 'softmax']}, "search_nodes_by_type_1.json")
]) ])
def test_search_nodes_by_type(self, node_type, condition, result_file): def test_search_nodes_by_type(self, node_type, condition, result_file):
"""Test search nodes by type.""" """Test search nodes by type."""


Loading…
Cancel
Save