1 # Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Test visqlib.DotBuilder module"""
19 from visqlib.DotBuilder import DotBuilder
20 from test.Resources import fp32_model_dir
23 class VisqDotBuilderTest(unittest.TestCase):
24 def test_dot_builder_wrong_input_file(self):
25 self.assertRaises(FileNotFoundError, DotBuilder, "wrong", "wrong", "wrong",
28 def test_dot_builder(self):
29 test_colors = [{"b": 0, "e": 0.5, "c": "green"}, {"b": 0.5, "e": 1, "c": "red"}]
30 test_qerror_map = dict()
31 test_qerror_map["ofm"] = 0.1
32 builder = DotBuilder(fp32_model_dir + "/Add_000.circle", "Add_000.dot", "MPEIR",
34 builder.save(test_qerror_map)
36 graph = pydot.graph_from_dot_file("Add_000.dot")[0]
38 ofm_node = graph.get_node("\"ofm\"")[1]
39 self.assertEqual("green", ofm_node.get_fillcolor())
42 if __name__ == "__main__":