| @@ -0,0 +1,14 @@ | |||||
| # 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. | |||||
| # ============================================================================ | |||||
| @@ -0,0 +1,14 @@ | |||||
| # 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. | |||||
| # ============================================================================ | |||||
| @@ -0,0 +1,11 @@ | |||||
| full_op_time,execution_time | |||||
| Default/AtomicAddrClean-op104,0.00133 | |||||
| Default/AtomicAddrClean-op105,0.000987 | |||||
| Default/AtomicAddrClean-op106,0.001129 | |||||
| Default/Cast-op10,0.00466 | |||||
| Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op12,0.002366 | |||||
| Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Cast-op53,0.004879 | |||||
| Default/TransData-op11,0.006366 | |||||
| Gradients/Default/network-WithLossCell/_backbone-LeNet5/gradReshape/TransData-op44,0.006782 | |||||
| Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Conv2D-op13,0.05651 | |||||
| Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/MatMul-op9,0.370864 | |||||
| @@ -0,0 +1,6 @@ | |||||
| op_type,execution_time,execution_frequency,percent | |||||
| AtomicAddrClean,0.007283,6,0.49 | |||||
| Cast,0.053395,13,3.63 | |||||
| TransData,0.121800,5,8.23 | |||||
| Conv2D,0.063656,2,4.33 | |||||
| MatMul,1.085982,9,73.80 | |||||
| @@ -0,0 +1,11 @@ | |||||
| task_id,stream_id,block_dim,full_op_name,op_name,op_type,subgraph,op_info | |||||
| 30290,0,1,Default/AtomicAddrClean-op104,AtomicAddrClean-op104,AtomicAddrClean,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": """"}}" | |||||
| 30295,0,1,Default/AtomicAddrClean-op105,AtomicAddrClean-op105,AtomicAddrClean,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""10""}}" | |||||
| 30300,0,1,Default/AtomicAddrClean-op106,AtomicAddrClean-op106,AtomicAddrClean,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""84""}}" | |||||
| 30268,0,32,Default/Cast-op10,Cast-op10,Cast,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""32,1,32,32""}, ""output_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,32,32""}}" | |||||
| 30271,0,9,Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Cast-op12,Cast-op12,Cast,Default,"{""input_0"": {""format"": ""FracZ"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""25,1,16,16""}, ""output_0"": {""format"": ""FracZ"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""25,1,16,16""}}" | |||||
| 30320,0,32,Gradients/Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/gradConv2D/Cast-op53,Cast-op53,Cast,Gradients,"{""input_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""32,1,28,28,16""}, ""output_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,28,28,16""}}" | |||||
| 30269,0,32,Default/TransData-op11,TransData-op11,TransData,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,32,32""}, ""output_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,32,32""}}" | |||||
| 30308,0,32,Gradients/Default/network-WithLossCell/_backbone-LeNet5/gradReshape/TransData-op44,TransData-op44,TransData,Gradients,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,16,5,5""}, ""output_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,5,5,16""}}" | |||||
| 30272,0,32,Default/network-WithLossCell/_backbone-LeNet5/conv1-Conv2d/Conv2D-op13,Conv2D-op13,Conv2D,Default,"{""input_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,32,32,16""}, ""input_1"": {""format"": ""FracZ"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""25,1,16,16""}, ""output_0"": {""format"": ""NC1HWC0"", ""data_type"": ""NUMBER_TYPE_FLOAT16"", ""shape"": ""32,1,28,28,16""}}" | |||||
| 30286,0,1,Default/network-WithLossCell/_backbone-LeNet5/fc3-Dense/MatMul-op9,MatMul-op9,MatMul,Default,"{""input_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""32,120""}, ""input_1"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""84,120""}, ""input_2"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""84""}, ""output_0"": {""format"": ""DefaultFormat"", ""data_type"": ""NUMBER_TYPE_FLOAT32"", ""shape"": ""32,84""}}" | |||||
| @@ -0,0 +1,301 @@ | |||||
| # 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 the analyser module.""" | |||||
| import csv | |||||
| import json | |||||
| import os | |||||
| from unittest import TestCase | |||||
| from mindinsight.profiler.analyser.analyser import AicoreDetailAnalyser | |||||
| from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory | |||||
| def get_detail_infos(indexes=None, sort_name=None, sort_type=True): | |||||
| """ | |||||
| Get AICORE operator detail information. | |||||
| Args: | |||||
| indexes (list[int]): The operator indexes. Default: None. | |||||
| sort_name (str): The sort name. Default: None. | |||||
| sort_type (bool): The sort type. If the parameter is `True`, the results | |||||
| are sorted in descending order, else `False`. Default: True. | |||||
| Returns: | |||||
| list[list], the AICORE operator detail information. | |||||
| """ | |||||
| profiling_dir = os.path.join(os.path.dirname(__file__), 'resource') | |||||
| framework_path = os.path.join(profiling_dir, 'framework_raw_0.csv') | |||||
| detail_path = os.path.join(profiling_dir, 'aicore_intermediate_0_detail.csv') | |||||
| with open(framework_path, 'r') as fm_file, open(detail_path, 'r') as detail_file: | |||||
| fm_csv_reader = csv.reader(fm_file) | |||||
| detail_csv_reader = csv.reader(detail_file) | |||||
| _ = next(fm_csv_reader) | |||||
| _ = next(detail_csv_reader) | |||||
| cache = [] | |||||
| for fm_info, detail_info in zip(fm_csv_reader, detail_csv_reader): | |||||
| cache.append( | |||||
| [fm_info[4], fm_info[5], float(detail_info[1]), fm_info[6], | |||||
| fm_info[3], json.loads(fm_info[7]) if fm_info[7] else None] | |||||
| ) | |||||
| if indexes: | |||||
| result = [cache[index] for index in indexes] | |||||
| else: | |||||
| result = cache | |||||
| if sort_name: | |||||
| sort_index = AicoreDetailAnalyser.__col_names__.index(sort_name) | |||||
| result.sort(key=lambda item: item[sort_index], reverse=sort_type) | |||||
| return result | |||||
| class TestAicoreDetailAnalyser(TestCase): | |||||
| """Test the class of `AicoreDetailAnalyser`.""" | |||||
| def setUp(self) -> None: | |||||
| """Initialization before test case execution.""" | |||||
| profiling_dir = os.path.join(os.path.dirname(__file__), 'resource') | |||||
| self._analyser = AnalyserFactory.instance().get_analyser( | |||||
| 'aicore_detail', profiling_dir, '0' | |||||
| ) | |||||
| def test_query_success_1(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos(), | |||||
| 'size': 10 | |||||
| } | |||||
| result = self._analyser.query({}) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| result = self._analyser.query() | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_2(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos(indexes=[9]), | |||||
| 'size': 1 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['MatMul'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'not_in': ['AtomicAddrClean', 'Cast', 'TransData', 'Conv2D'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_name': { | |||||
| 'partial_match_str_in': ['op9'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_3(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos(sort_name='execution_time', sort_type=True), | |||||
| 'size': 10 | |||||
| } | |||||
| condition = { | |||||
| 'sort_condition': { | |||||
| 'name': 'execution_time', | |||||
| 'type': 'descending' | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos(sort_name='op_name', sort_type=False), | |||||
| 'size': 10 | |||||
| } | |||||
| condition = { | |||||
| 'sort_condition': { | |||||
| 'name': 'op_name', | |||||
| 'type': 'ascending' | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_4(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos(indexes=[2, 3]), | |||||
| 'size': 10 | |||||
| } | |||||
| condition = { | |||||
| 'group_condition': { | |||||
| 'limit': 2, | |||||
| 'offset': 1 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': [], | |||||
| 'size': 10 | |||||
| } | |||||
| condition = { | |||||
| 'group_condition': { | |||||
| 'limit': 2, | |||||
| 'offset': 5 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_5(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos( | |||||
| indexes=[1, 2], sort_name='execution_time', sort_type=True | |||||
| ), | |||||
| 'size': 4 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_name': { | |||||
| 'partial_match_str_in': ['Atomic', 'Conv'] | |||||
| } | |||||
| }, | |||||
| 'sort_condition': { | |||||
| 'name': 'execution_time' | |||||
| }, | |||||
| 'group_condition': { | |||||
| 'limit': 2, | |||||
| 'offset': 1 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__, | |||||
| 'object': get_detail_infos( | |||||
| indexes=[0, 1, 2, 8], sort_name='execution_time', sort_type=True | |||||
| ), | |||||
| 'size': 4 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['Conv2D', 'AtomicAddrClean', 'TransData'] | |||||
| }, | |||||
| 'op_name': { | |||||
| 'partial_match_str_in': ['Atomic', 'Conv'] | |||||
| } | |||||
| }, | |||||
| 'sort_condition': { | |||||
| 'name': 'execution_time' | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_6(self): | |||||
| """Test the success of the querying function.""" | |||||
| detail_infos = get_detail_infos(indexes=[9]) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__[0:5], | |||||
| 'object': [item[0:5] for item in detail_infos], | |||||
| 'size': 1 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['MatMul'] | |||||
| }, | |||||
| 'is_display_detail': False | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__[0:4], | |||||
| 'object': [item[0:4] for item in detail_infos], | |||||
| 'size': 1 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['MatMul'] | |||||
| }, | |||||
| 'is_display_detail': False, | |||||
| 'is_display_full_op_name': False | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_and_sort_by_op_type(self): | |||||
| """Test the success of the querying and sorting function by operator type.""" | |||||
| detail_infos = get_detail_infos(indexes=[9, 0, 2, 1, 5, 3, 4]) | |||||
| expect_result = { | |||||
| 'col_name': AicoreDetailAnalyser.__col_names__[0:4], | |||||
| 'object': [item[0:4] for item in detail_infos] | |||||
| } | |||||
| filter_condition = { | |||||
| 'op_type': { | |||||
| 'in': ['AtomicAddrClean', 'Cast', 'MatMul'], | |||||
| 'not_in': ['TransData'] | |||||
| }, | |||||
| 'is_display_detail': False, | |||||
| 'is_display_full_op_name': False | |||||
| } | |||||
| op_type_order = ['MatMul', 'AtomicAddrClean', 'Cast'] | |||||
| result = self._analyser.query_and_sort_by_op_type( | |||||
| filter_condition, op_type_order | |||||
| ) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_col_names(self): | |||||
| """Test the querying column names function.""" | |||||
| self.assertListEqual( | |||||
| AicoreDetailAnalyser.__col_names__, self._analyser.col_names | |||||
| ) | |||||
| def test_data(self): | |||||
| """Test the querying data function.""" | |||||
| expect_result = get_detail_infos() | |||||
| self.assertListEqual(expect_result, self._analyser.data) | |||||
| @@ -0,0 +1,274 @@ | |||||
| # 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 the analyser module.""" | |||||
| import csv | |||||
| import os | |||||
| from unittest import TestCase | |||||
| from mindinsight.profiler.analyser.analyser import AicoreTypeAnalyser | |||||
| from mindinsight.profiler.analyser.analyser_factory import AnalyserFactory | |||||
| def get_type_infos(indexes=None, sort_name=None, sort_type=True): | |||||
| """ | |||||
| Get AICORE operator type information. | |||||
| Args: | |||||
| indexes (list[int]): The operator indexes. Default: None. | |||||
| sort_name (str): The sort name. Default: None. | |||||
| sort_type (bool): The sort type. If the parameter is `True`, the results | |||||
| are sorted in descending order, else `False`. Default: True. | |||||
| Returns: | |||||
| list[list], the AICORE operator type information. | |||||
| """ | |||||
| profiling_dir = os.path.join(os.path.dirname(__file__), 'resource') | |||||
| aicore_type_path = os.path.join( | |||||
| profiling_dir, 'aicore_intermediate_0_type.csv' | |||||
| ) | |||||
| with open(aicore_type_path, 'r') as aicore_type_path: | |||||
| csv_reader = csv.reader(aicore_type_path) | |||||
| _ = next(csv_reader) | |||||
| cache = [] | |||||
| for type_info in csv_reader: | |||||
| cache.append( | |||||
| [type_info[0], float(type_info[1]), int(type_info[2]), | |||||
| float(type_info[3])] | |||||
| ) | |||||
| if indexes: | |||||
| result = [cache[index] for index in indexes] | |||||
| else: | |||||
| result = cache | |||||
| if sort_name: | |||||
| sort_index = AicoreTypeAnalyser.__col_names__.index(sort_name) | |||||
| result.sort(key=lambda item: item[sort_index], reverse=sort_type) | |||||
| return result | |||||
| class TestAicoreTypeAnalyser(TestCase): | |||||
| """Test the class of `AicoreTypeAnalyser`.""" | |||||
| def setUp(self) -> None: | |||||
| """Initialization before test case execution.""" | |||||
| profiling_dir = os.path.join(os.path.dirname(__file__), 'resource') | |||||
| self._analyser = AnalyserFactory.instance().get_analyser( | |||||
| 'aicore_type', profiling_dir, '0' | |||||
| ) | |||||
| def test_query_success_1(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(), | |||||
| 'size': 5 | |||||
| } | |||||
| condition = {} | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| result = self._analyser.query() | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_2(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[1]), | |||||
| 'size': 1 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['Cast'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[0, 2, 3, 4]), | |||||
| 'size': 4 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'not_in': ['Cast'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[0, 1, 3]), | |||||
| 'size': 3 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'partial_match_str_in': ['C'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_3(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[1, 3]), | |||||
| 'size': 2 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'in': ['Cast', 'Conv2D'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[0, 2, 4]), | |||||
| 'size': 3 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'not_in': ['Cast', 'Conv2D'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[2, 3]), | |||||
| 'size': 2 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'partial_match_str_in': ['Trans', 'Conv'] | |||||
| } | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_4(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(sort_name='op_type', sort_type=True), | |||||
| 'size': 5} | |||||
| condition = { | |||||
| 'sort_condition': { | |||||
| 'name': 'op_type', | |||||
| 'type': 'descending' | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(sort_name='execution_time', sort_type=False), | |||||
| 'size': 5 | |||||
| } | |||||
| condition = { | |||||
| 'sort_condition': { | |||||
| 'name': 'execution_time', | |||||
| 'type': 'ascending' | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_5(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[0, 1]), | |||||
| 'size': 5 | |||||
| } | |||||
| condition = { | |||||
| 'group_condition': { | |||||
| 'limit': 2, | |||||
| 'offset': 0 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos(indexes=[3, 4]), | |||||
| 'size': 5 | |||||
| } | |||||
| condition = { | |||||
| 'group_condition': { | |||||
| 'limit': 3, | |||||
| 'offset': 1 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_query_success_6(self): | |||||
| """Test the success of the querying function.""" | |||||
| expect_result = { | |||||
| 'col_name': AicoreTypeAnalyser.__col_names__, | |||||
| 'object': get_type_infos( | |||||
| indexes=[1, 3], sort_name='execution_time', sort_type=True | |||||
| ), | |||||
| 'size': 3 | |||||
| } | |||||
| condition = { | |||||
| 'filter_condition': { | |||||
| 'op_type': { | |||||
| 'partial_match_str_in': ['C'] | |||||
| } | |||||
| }, | |||||
| 'sort_condition': { | |||||
| 'name': 'execution_time' | |||||
| }, | |||||
| 'group_condition': { | |||||
| 'limit': 2, | |||||
| 'offset': 0 | |||||
| } | |||||
| } | |||||
| result = self._analyser.query(condition) | |||||
| self.assertDictEqual(expect_result, result) | |||||
| def test_col_names(self): | |||||
| """Test the querying column names function.""" | |||||
| self.assertListEqual( | |||||
| AicoreTypeAnalyser.__col_names__, self._analyser.col_names | |||||
| ) | |||||
| def test_data(self): | |||||
| """Test the querying data function.""" | |||||
| expect_result = get_type_infos() | |||||
| self.assertListEqual(expect_result, self._analyser.data) | |||||