From 7a1d5fb0fd310d8753c917db60499f671ff5cf75 Mon Sep 17 00:00:00 2001 From: zhangyunshu Date: Thu, 24 Sep 2020 16:40:13 +0800 Subject: [PATCH] deugger: add ut for graph and watch point --- tests/ut/debugger/__init__.py | 15 ++ tests/ut/debugger/configurations.py | 95 +++++++++ ...ph_handler_get_1_no_filter_condintion.json | 1 + .../graph/graph_handler_get_2_list_nodes.json | 1 + .../graph_handler_get_3_single_node.json | 0 .../graph}/search_node_1.json | 0 .../graph/search_nodes_0.json | 1 + .../expected_results/graph}/tenor_hist_0.json | 0 .../graph}/tensor_hist_1.json | 0 tests/ut/debugger/stream_handler/__init__.py | 15 ++ .../stream_handler}/test_graph_handler.py | 62 ++---- .../stream_handler/test_watchpoint_handler.py | 183 ++++++++++++++++++ 12 files changed, 324 insertions(+), 49 deletions(-) create mode 100644 tests/ut/debugger/__init__.py create mode 100644 tests/ut/debugger/configurations.py create mode 100644 tests/ut/debugger/expected_results/graph/graph_handler_get_1_no_filter_condintion.json create mode 100644 tests/ut/debugger/expected_results/graph/graph_handler_get_2_list_nodes.json rename tests/{st/func/debugger/expect_results => ut/debugger/expected_results/graph}/graph_handler_get_3_single_node.json (100%) rename tests/{st/func/debugger/expect_results => ut/debugger/expected_results/graph}/search_node_1.json (100%) create mode 100644 tests/ut/debugger/expected_results/graph/search_nodes_0.json rename tests/{st/func/debugger/expect_results => ut/debugger/expected_results/graph}/tenor_hist_0.json (100%) rename tests/{st/func/debugger/expect_results => ut/debugger/expected_results/graph}/tensor_hist_1.json (100%) create mode 100644 tests/ut/debugger/stream_handler/__init__.py rename tests/{st/func/debugger => ut/debugger/stream_handler}/test_graph_handler.py (68%) create mode 100644 tests/ut/debugger/stream_handler/test_watchpoint_handler.py diff --git a/tests/ut/debugger/__init__.py b/tests/ut/debugger/__init__.py new file mode 100644 index 00000000..95a33e57 --- /dev/null +++ b/tests/ut/debugger/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +"""Test for debugger module.""" diff --git a/tests/ut/debugger/configurations.py b/tests/ut/debugger/configurations.py new file mode 100644 index 00000000..c9a3fb12 --- /dev/null +++ b/tests/ut/debugger/configurations.py @@ -0,0 +1,95 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +"""Common configurations for debugger unit testing.""" +import json +import os + +from google.protobuf import json_format + +from mindinsight.debugger.proto import ms_graph_pb2 +from mindinsight.debugger.stream_handler.graph_handler import GraphHandler + +graph_proto_file = os.path.join( + os.path.dirname(__file__), '../../utils/resource/graph_pb/lenet.pb' +) + + +def get_graph_proto(): + """Get graph proto.""" + with open(graph_proto_file, 'rb') as f: + content = f.read() + + graph = ms_graph_pb2.GraphProto() + graph.ParseFromString(content) + + return graph + + +def init_graph_handler(): + """Init graph proto.""" + graph = get_graph_proto() + graph_handler = GraphHandler() + graph_handler.put(graph) + + return graph_handler + + +def mock_tensor_proto(): + """Mock tensor proto.""" + tensor_dict = { + "node_name": + "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92", + "slot": "0" + } + tensor_proto = json_format.Parse(json.dumps(tensor_dict), ms_graph_pb2.TensorProto()) + + return tensor_proto + + +def mock_tensor_history(): + """Mock tensor history.""" + tensor_history = { + "tensor_history": [ + {"name": "Default/TransData-op99:0", + "full_name": "Default/TransData-op99:0", + "node_type": "TransData", + "type": "output", + "step": 0, + "dtype": "DT_FLOAT32", + "shape": [2, 3], + "has_prev_step": False, + "value": "click to view"}, + {"name": "Default/args0:0", + "full_name": "Default/args0:0", + "node_type": "Parameter", + "type": "input", + "step": 0, + "dtype": "DT_FLOAT32", + "shape": [2, 3], + "has_prev_step": False, + "value": "click to view"} + ], + "metadata": { + "state": "waiting", + "step": 0, + "device_name": "0", + "pos": "0", + "ip": "127.0.0.1:57492", + "node_name": "", + "backend": "Ascend" + } + } + + return tensor_history diff --git a/tests/ut/debugger/expected_results/graph/graph_handler_get_1_no_filter_condintion.json b/tests/ut/debugger/expected_results/graph/graph_handler_get_1_no_filter_condintion.json new file mode 100644 index 00000000..5d457b6e --- /dev/null +++ b/tests/ut/debugger/expected_results/graph/graph_handler_get_1_no_filter_condintion.json @@ -0,0 +1 @@ +{"graph": {"nodes": [{"name": "Default", "type": "name_scope", "attr": {}, "input": {"Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op21": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op24": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op29": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op32": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op37": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op40": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropFilter-op48": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Conv2DBackpropFilter-op55": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output": {"Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropInput-op52": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Conv2DBackpropFilter-op55": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op53": {"shape": [[32, 6, 4, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op46": {"shape": [[32, 16, 4, 3]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op40": {"shape": [[32, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGrad-op36": {"shape": [[32, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op32": {"shape": [[32, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGrad-op28": {"shape": [[32, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op24": {"shape": [[32, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropFilter-op48": {"shape": [[32, 6, 14, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/gradSoftmaxCrossEntropyWithLogits/Mul-op20": {"shape": [[32, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92": {"shape": [[32, 1, 10, 10, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op94": {"shape": [[32, 1, 28, 28, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 7, "independent_layout": false}, {"name": "Gradients", "type": "name_scope", "attr": {}, "input": {"Default/tuple_getitem[10]_0/tuple_getitem-op210": {"shape": [[32, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op15": {"shape": [[32, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLU-op12": {"shape": [[32, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/Cast-op205": {"shape": [[32, 16, 10, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op206": {"shape": [[32, 16, 4, 3]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op202": {"shape": [[32, 1, 10, 10, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op197": {"shape": [[32, 6, 14, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/Cast-op188": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/Cast-op195": {"shape": [[32, 6, 28, 28]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op196": {"shape": [[32, 6, 4, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op192": {"shape": [[32, 1, 28, 28, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}, "Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/flatten-Flatten/Reshape-op9": {"shape": [[32, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output": {"Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op22": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op30": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op38": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op49": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op56": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op25": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op33": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/ApplyMomentum[8]_1/ApplyMomentum-op41": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 1, "independent_layout": false}]}} \ No newline at end of file diff --git a/tests/ut/debugger/expected_results/graph/graph_handler_get_2_list_nodes.json b/tests/ut/debugger/expected_results/graph/graph_handler_get_2_list_nodes.json new file mode 100644 index 00000000..4fb0c364 --- /dev/null +++ b/tests/ut/debugger/expected_results/graph/graph_handler_get_2_list_nodes.json @@ -0,0 +1 @@ +{"graph": {"nodes": [{"name": "Default/TransData-op99", "type": "TransData", "attr": {"dst_format": "dtype: DT_STRING\nstr_val: \"NC1HWC0\"\n", "IsFeatureMapInputList": "dtype: DT_TUPLE\nvalues {\n dtype: DT_UINT64\n uint_val: 0\n}\n", "pri_format": "dtype: DT_STRING\nstr_val: \"NC1HWC0\"\n", "_datadump_original_names": "dtype: DT_TUPLE\n", "IsFeatureMapOutput": "dtype: DT_BOOL\nbool_val: true\n", "src_format": "dtype: DT_STRING\nstr_val: \"NCHW\"\n"}, "input": {"Default/args0": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output": {"Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 0, "independent_layout": false}, {"name": "Default/Depend-op61", "type": "Depend", "attr": {}, "input": {"Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/ReduceMean-op60": {"shape": [[]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/make_tuple-op58": {"shape": [[], [], [], [], [], [], [], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL']"}}, "output": {"Default/make_tuple[9]_3/make_tuple-op284": {"shape": [[]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 0, "independent_layout": false}, {"name": "Default/args0", "type": "Parameter", "attr": {"type": "DT_TENSOR[DT_FLOAT32]", "shape": "[[32, 1, 32, 32]]"}, "input": {}, "output": {"Default/TransData-op99": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 0, "independent_layout": false}, {"name": "Default/tuple_getitem[10]_0", "type": "aggregation_scope", "attr": {}, "input": {"Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op87": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/MaxPoolWithArgmax-op3": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/MaxPoolWithArgmax-op7": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/SoftmaxCrossEntropyWithLogits-op18": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}}, "output": {"Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/Cast-op195": {"shape": [[32, 6, 28, 28]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/Conv2D-op5": {"shape": [[32, 6, 14, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropFilter-op48": {"shape": [[32, 6, 14, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/Cast-op205": {"shape": [[32, 16, 10, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/Cast-op208": {"shape": [[32, 16, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/gradSoftmaxCrossEntropyWithLogits/Mul-op20": {"shape": [[32, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92": {"shape": [[32, 1, 10, 10, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op46": {"shape": [[32, 16, 4, 3]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op94": {"shape": [[32, 1, 28, 28, 2]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT8]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op53": {"shape": [[32, 6, 4, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_UINT16]"}, "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/ReduceMean-op60": {"shape": [[32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 20, "independent_layout": false}, {"name": "Default/make_tuple[9]_3", "type": "aggregation_scope", "attr": {}, "input": {"Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op250": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op251": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op253": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op254": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op256": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op257": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op259": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op260": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op262": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op263": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op265": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op266": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op268": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op269": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op271": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/optimizer-Momentum/tuple_getitem[16]_2/tuple_getitem-op272": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/Depend-op61": {"shape": [[]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output": {"Default/optimizer-Momentum/Depend[8]_4/Depend-op23": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op26": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op31": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op34": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op39": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op42": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op50": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/optimizer-Momentum/Depend[8]_4/Depend-op57": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 9, "independent_layout": false}, {"name": "Default/network-WithLossCell", "type": "name_scope", "attr": {}, "input": {"Default/TransData-op99": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op193": {"shape": [[32, 6, 28, 28]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op197": {"shape": [[32, 6, 14, 14]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op203": {"shape": [[32, 16, 10, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op207": {"shape": [[32, 16, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op211": {"shape": [[32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output": {"Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropInput-op52": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Conv2DBackpropFilter-op55": {"shape": [[32, 1, 32, 32]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op193": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op192": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op53": {"shape": [[32, 6, 28, 28]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op197": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op196": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op203": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op202": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT8]']"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/max_pool2d-MaxPool2d/gradMaxPoolWithArgmax/MaxPoolGradWithArgmax-op46": {"shape": [[32, 16, 10, 10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op207": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op206": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_UINT16]']"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op40": {"shape": [[32, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGrad-op36": {"shape": [[32, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op32": {"shape": [[32, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGrad-op28": {"shape": [[32, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op24": {"shape": [[32, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/tuple_getitem[10]_0/tuple_getitem-op210": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/tuple_getitem[10]_0/tuple_getitem-op211": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/Depend-op61": {"shape": [[]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 2, "independent_layout": false}, {"name": "Default/optimizer-Momentum", "type": "name_scope", "attr": {}, "input": {"Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op21": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op24": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op29": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op32": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradBiasAdd/BiasAddGrad-op37": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/gradMatMul/MatMul[6]_5/MatMul-op40": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv2-Conv2d/gradConv2D/Conv2DBackpropFilter-op48": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Conv2DBackpropFilter-op55": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op65": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op68": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op71": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op74": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op77": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op80": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op83": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}, "Default/make_tuple[9]_3/make_tuple-op86": {"shape": [[], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_TENSOR[DT_FLOAT32]', 'DT_TENSOR[DT_FLOAT32]']"}}, "output": {"Default/Depend-op61": {"shape": [[], [], [], [], [], [], [], []], "edge_type": "data", "independent_layout": false, "data_type": "DT_TUPLE['DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL', 'DT_BOOL']"}, "Default/make_tuple[9]_3/make_tuple-op65": {"shape": [[10]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op68": {"shape": [[10, 84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op71": {"shape": [[84]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op74": {"shape": [[84, 120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op77": {"shape": [[120]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op80": {"shape": [[120, 400]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op83": {"shape": [[16, 6, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}, "Default/make_tuple[9]_3/make_tuple-op86": {"shape": [[6, 1, 5, 5]], "edge_type": "data", "independent_layout": false, "data_type": "DT_TENSOR[DT_FLOAT32]"}}, "output_i": 0, "proxy_input": {}, "proxy_output": {}, "subnode_count": 5, "independent_layout": false}]}} \ No newline at end of file diff --git a/tests/st/func/debugger/expect_results/graph_handler_get_3_single_node.json b/tests/ut/debugger/expected_results/graph/graph_handler_get_3_single_node.json similarity index 100% rename from tests/st/func/debugger/expect_results/graph_handler_get_3_single_node.json rename to tests/ut/debugger/expected_results/graph/graph_handler_get_3_single_node.json diff --git a/tests/st/func/debugger/expect_results/search_node_1.json b/tests/ut/debugger/expected_results/graph/search_node_1.json similarity index 100% rename from tests/st/func/debugger/expect_results/search_node_1.json rename to tests/ut/debugger/expected_results/graph/search_node_1.json diff --git a/tests/ut/debugger/expected_results/graph/search_nodes_0.json b/tests/ut/debugger/expected_results/graph/search_nodes_0.json new file mode 100644 index 00000000..44bb7437 --- /dev/null +++ b/tests/ut/debugger/expected_results/graph/search_nodes_0.json @@ -0,0 +1 @@ +{"nodes": [{"name": "Default", "type": null, "nodes": [{"name": "Default/network-WithLossCell", "type": null, "nodes": [{"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits", "type": null, "nodes": [{"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/OneHot-op0", "type": "OneHot", "nodes": []}, {"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/SoftmaxCrossEntropyWithLogits-op18", "type": "SoftmaxCrossEntropyWithLogits", "nodes": []}, {"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/ReduceMean-op60", "type": "ReduceMean", "nodes": []}, {"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/args1", "type": "Parameter", "nodes": []}, {"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/cst1", "type": "Const", "nodes": []}, {"name": "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/cst2", "type": "Const", "nodes": []}]}]}]}, {"name": "Gradients", "type": null, "nodes": [{"name": "Gradients/Default", "type": null, "nodes": [{"name": "Gradients/Default/network-WithLossCell", "type": null, "nodes": [{"name": "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits", "type": null, "nodes": [{"name": "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/gradSoftmaxCrossEntropyWithLogits", "type": null, "nodes": [{"name": "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/gradSoftmaxCrossEntropyWithLogits/Mul-op20", "type": "Mul", "nodes": []}, {"name": "Gradients/Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/gradSoftmaxCrossEntropyWithLogits/cst8", "type": "Const", "nodes": []}]}]}]}]}]}]} \ No newline at end of file diff --git a/tests/st/func/debugger/expect_results/tenor_hist_0.json b/tests/ut/debugger/expected_results/graph/tenor_hist_0.json similarity index 100% rename from tests/st/func/debugger/expect_results/tenor_hist_0.json rename to tests/ut/debugger/expected_results/graph/tenor_hist_0.json diff --git a/tests/st/func/debugger/expect_results/tensor_hist_1.json b/tests/ut/debugger/expected_results/graph/tensor_hist_1.json similarity index 100% rename from tests/st/func/debugger/expect_results/tensor_hist_1.json rename to tests/ut/debugger/expected_results/graph/tensor_hist_1.json diff --git a/tests/ut/debugger/stream_handler/__init__.py b/tests/ut/debugger/stream_handler/__init__.py new file mode 100644 index 00000000..17d2c558 --- /dev/null +++ b/tests/ut/debugger/stream_handler/__init__.py @@ -0,0 +1,15 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +"""Test for debugger stream handler.""" diff --git a/tests/st/func/debugger/test_graph_handler.py b/tests/ut/debugger/stream_handler/test_graph_handler.py similarity index 68% rename from tests/st/func/debugger/test_graph_handler.py rename to tests/ut/debugger/stream_handler/test_graph_handler.py index 56d4d88d..f4bf5ab8 100644 --- a/tests/st/func/debugger/test_graph_handler.py +++ b/tests/ut/debugger/stream_handler/test_graph_handler.py @@ -16,31 +16,30 @@ Function: Test query debugger graph handler. Usage: - pytest tests/st/func/debugger/test_graph_handler.py + pytest tests/ut/debugger """ import os import pytest -from ....utils.tools import compare_result_with_file -from .conftest import init_graph_handler +from tests.ut.debugger.configurations import init_graph_handler +from tests.utils.tools import compare_result_with_file class TestGraphHandler: """Test GraphHandler.""" - graph_results_dir = os.path.join(os.path.dirname(__file__), 'expect_results') - graph_handler = init_graph_handler() + @classmethod + def setup_class(cls): + """Init WatchpointHandler for watchpoint unittest.""" + cls.graph_results_dir = os.path.join(os.path.dirname(__file__), + '../expected_results/graph') + cls.graph_handler = init_graph_handler() - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("filter_condition, result_file", [ (None, "graph_handler_get_1_no_filter_condintion.json"), ({'name': 'Default'}, "graph_handler_get_2_list_nodes.json"), - ({'name': 'Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190', 'single_node': True}, + ({'name': 'Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190', + 'single_node': True}, "graph_handler_get_3_single_node.json") ]) def test_get(self, filter_condition, result_file): @@ -49,12 +48,6 @@ class TestGraphHandler: file_path = os.path.join(self.graph_results_dir, result_file) compare_result_with_file(result, file_path) - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("node_name, result_file", [ ("Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190", "tenor_hist_0.json"), @@ -67,12 +60,6 @@ class TestGraphHandler: file_path = os.path.join(self.graph_results_dir, result_file) compare_result_with_file(result, file_path) - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("pattern, result_file", [ ("withlogits", "search_nodes_0.json"), ("cst", "search_node_1.json") @@ -83,12 +70,6 @@ class TestGraphHandler: file_path = os.path.join(self.graph_results_dir, result_file) compare_result_with_file(result, file_path) - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("node_name, expect_type", [ ("Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/cst1", 'Const'), ("Default/TransData-op99", "TransData") @@ -98,12 +79,6 @@ class TestGraphHandler: node_type = self.graph_handler.get_node_type(node_name) assert node_type == expect_type - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("node_name, expect_full_name", [ (None, ""), ("Default/make_tuple[9]_3/make_tuple-op284", "Default/make_tuple-op284"), @@ -114,12 +89,6 @@ class TestGraphHandler: full_name = self.graph_handler.get_full_name(node_name) assert full_name == expect_full_name - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("full_name, expect_node_name", [ (None, ""), ("Default/make_tuple-op284", "Default/make_tuple[9]_3/make_tuple-op284"), @@ -130,14 +99,9 @@ class TestGraphHandler: node_name = self.graph_handler.get_node_name_by_full_name(full_name) assert node_name == expect_node_name - @pytest.mark.level0 - @pytest.mark.env_single - @pytest.mark.platform_x86_cpu - @pytest.mark.platform_arm_ascend_training - @pytest.mark.platform_x86_gpu_training - @pytest.mark.platform_x86_ascend_training @pytest.mark.parametrize("node_name, ascend, expect_next", [ - (None, True, "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/OneHot-op0"), + (None, True, + "Default/network-WithLossCell/_loss_fn-SoftmaxCrossEntropyWithLogits/OneHot-op0"), (None, False, None), ("Default/tuple_getitem[10]_0/tuple_getitem-op206", True, "Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/ReLUV2-op89"), diff --git a/tests/ut/debugger/stream_handler/test_watchpoint_handler.py b/tests/ut/debugger/stream_handler/test_watchpoint_handler.py new file mode 100644 index 00000000..27b093af --- /dev/null +++ b/tests/ut/debugger/stream_handler/test_watchpoint_handler.py @@ -0,0 +1,183 @@ +# Copyright 2020 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +"""Test WatchpointHandler.""" +import json +import os +from unittest import mock, TestCase + +import pytest + +from mindinsight.debugger.common.exceptions.exceptions import DebuggerParamValueError, \ + DebuggerParamTypeError +from mindinsight.debugger.common.log import logger as log +from mindinsight.debugger.stream_cache.watchpoint import Watchpoint +from mindinsight.debugger.stream_handler.watchpoint_handler import WatchpointHandler, \ + WatchpointHitHandler, validate_watch_condition, validate_watch_condition_params + +from tests.ut.debugger.configurations import init_graph_handler, mock_tensor_proto, \ + mock_tensor_history + + +class TestWatchpointHandler: + """Test WatchpointHandler.""" + @classmethod + def setup_class(cls): + """Init WatchpointHandler for watchpoint unittest.""" + cls.handler = WatchpointHandler() + cls.graph_results_dir = os.path.join(os.path.dirname(__file__), + '../expected_results/graph') + cls.graph_stream = init_graph_handler() + + @pytest.mark.parametrize( + "watch_condition, watch_nodes, watch_point_id, expect_new_id", [ + ({'condition': 'INF'}, None, None, 1), + ({'condition': 'INF'}, ["Default"], None, 2), + ({'condition': 'MAX_GT', 'param': 1}, + ["Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92"], None, 3) + ]) + @mock.patch.object(Watchpoint, 'add_nodes') + def test_create_watchpoint(self, mock_add_nodes, watch_condition, watch_nodes, + watch_point_id, expect_new_id): + """Test create_watchpoint.""" + mock_add_nodes.return_value = None + watch_point_id = self.handler.create_watchpoint(watch_condition, watch_nodes, watch_point_id) + assert watch_point_id == expect_new_id + + @pytest.mark.parametrize("filter_condition", [True, False]) + @mock.patch.object(Watchpoint, 'get_set_cmd') + @mock.patch.object(Watchpoint, 'get_watch_condition_info') + def test_get(self, mock_get_wp, mock_get_cmd, filter_condition): + """Test get.""" + mock_get_wp.return_value = None + mock_get_cmd.return_value = None + with TestCase().assertLogs(logger=log, level='DEBUG') as log_content: + self.handler.get(filter_condition) + TestCase().assertIn(f"DEBUG:debugger.debugger:get the watch points with filter_condition:{filter_condition}", + log_content.output) + + def test_get_watchpoint_by_id_except(self): + """Test get_watchpoint_by_id.""" + watchpoint_id = 4 + with pytest.raises(DebuggerParamValueError) as err: + self.handler.get_watchpoint_by_id(watchpoint_id) + assert err.value.error_code == '5054B081' + assert err.value.message == f"ValueError. Invalid watchpoint id {watchpoint_id}" + + @pytest.mark.parametrize("graph_file, watch_point_id", [ + ('graph_handler_get_3_single_node.json', 4) + ]) + @mock.patch.object(WatchpointHandler, '_set_watch_status_recursively') + def test_set_watch_nodes(self, mock_set_recur, graph_file, watch_point_id): + """Test set_watch_nodes.""" + path = os.path.join(self.graph_results_dir, graph_file) + with open(path, 'r') as f: + graph = json.load(f) + instance = mock_set_recur.return_value + self.handler.set_watch_nodes(graph, self.graph_stream, watch_point_id) + assert instance.iscalled() + + @pytest.mark.parametrize( + "watch_point_id, watch_nodes, watched, expect_updated_id", [ + (2, ["Default"], 0, 2), + (3, ["Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92"], 1, 3) + ]) + @mock.patch.object(Watchpoint, 'remove_nodes') + @mock.patch.object(Watchpoint, 'add_nodes') + def test_update_watchpoint(self, mock_add_nodes, mock_remove_nodes, watch_point_id, watch_nodes, + watched, expect_updated_id): + """Test update_watchpoint.""" + mock_add_nodes.return_value = None + mock_remove_nodes.return_value = None + with TestCase().assertLogs(logger=log, level='DEBUG') as log_content: + self.handler.update_watchpoint(watch_point_id, watch_nodes, watched) + TestCase().assertIn(f"DEBUG:debugger.debugger:Update watchpoint {expect_updated_id} in cache.", + log_content.output) + + @pytest.mark.parametrize( + "watch_point_id, expect_deleted_ids", [ + (3, 3), (2, 2) + ]) + def test_delete_watchpoint(self, watch_point_id, expect_deleted_ids): + """Test delete_watchpoint.""" + with TestCase().assertLogs(logger=log, level='DEBUG') as log_content: + self.handler.delete_watchpoint(watch_point_id) + TestCase().assertIn(f"DEBUG:debugger.debugger:Delete watchpoint {expect_deleted_ids} in cache.", + log_content.output) + + +class TestWatchpointHitHandler: + """Test WatchpointHitHandler.""" + @classmethod + def setup_class(cls): + """Setup.""" + cls.handler = WatchpointHitHandler() + cls.tensor_proto = mock_tensor_proto() + cls.tensor_hist = mock_tensor_history() + + @mock.patch('mindinsight.debugger.stream_cache.watchpoint.WatchpointHit') + def test_put(self, mock_hit): + """Test put.""" + value = { + 'tensor_proto': self.tensor_proto, + 'watchpoint': {'id': 1, 'watch_condition': {'condition': 'INF'}}, + 'node_name': 'Gradients/Default/network-WithLossCell/_backbone-LeNet5/relu-ReLU/gradReLU/ReluGradV2-op92' + } + mock_hit.return_value = mock.MagicMock( + tensor_proto=value.get('tensor_proto'), + watchpoint=value.get('watchpoint'), + node_name=value.get('node_name') + ) + self.handler.put(value) + + @pytest.mark.parametrize("filter_condition", [ + None, "Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op190" + ]) + @mock.patch.object(WatchpointHitHandler, 'get_watchpoint_hits') + def test_get(self, mock_get, filter_condition): + """Test get.""" + mock_get.return_value = {'watch_point_hits': []} + self.handler.get(filter_condition) + + @mock.patch.object(WatchpointHitHandler, '_is_tensor_hit') + def test_update_tensor_history(self, mock_hit): + """Test update_tensor_history.""" + mock_hit.side_effect = [True, False] + self.handler.update_tensor_history(self.tensor_hist) + + +def test_validate_watch_condition_type_error(): + """Test validate_watch_condition.""" + watch_condition = [] + with pytest.raises(DebuggerParamTypeError) as err: + validate_watch_condition(watch_condition) + assert err.value.error_code == '5054B080' + + watch_condition = {'watch_condition': {'condition': 'MAXIMUM'}} + with pytest.raises(DebuggerParamValueError) as err: + validate_watch_condition(watch_condition) + assert err.value.error_code == '5054B081' + + +def test_validate_watch_condition_params_except(): + """Test validate_watch_condition_params.""" + watch_condition = {'watch_condition': {'condition': 'NAN', 'param': 1}} + with pytest.raises(DebuggerParamValueError) as err: + validate_watch_condition_params(watch_condition) + assert err.value.error_code == '5054B081' + + watch_condition = {'watch_condition': {'condition': 'MAX_GT', 'param': '0'}} + with pytest.raises(DebuggerParamValueError) as err: + validate_watch_condition_params(watch_condition) + assert err.value.error_code == '5054B081'