FrozenGene commented on a change in pull request #6578:
URL: https://github.com/apache/incubator-tvm/pull/6578#discussion_r498376833



##########
File path: tests/python/driver/tvmc/test_runner.py
##########
@@ -0,0 +1,98 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you 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.
+import pytest
+import numpy as np
+
+from tvm.driver import tvmc
+
+
+def test_generate_tensor_data_zeros():
+    expected_shape = (2, 3)
+    expected_dtype = "uint8"
+    sut = tvmc.runner.generate_tensor_data(expected_shape, expected_dtype, 
"zeros")
+
+    assert sut.shape == (2, 3)
+
+
+def test_generate_tensor_data_ones():
+    expected_shape = (224, 224)
+    expected_dtype = "uint8"
+    sut = tvmc.runner.generate_tensor_data(expected_shape, expected_dtype, 
"ones")
+
+    assert sut.shape == (224, 224)
+
+
+def test_generate_tensor_data_random():
+    expected_shape = (2, 3)
+    expected_dtype = "uint8"
+    sut = tvmc.runner.generate_tensor_data(expected_shape, expected_dtype, 
"random")
+
+    assert sut.shape == (2, 3)
+
+
+def test_generate_tensor_data__type_unknown():
+    with pytest.raises(tvmc.common.TVMCException) as e:
+        tvmc.runner.generate_tensor_data((2, 3), "float32", "whatever")
+
+
+def test_format_times__contains_header():
+    sut = tvmc.runner.format_times([60, 120, 12, 42])
+    assert "std (s)" in sut
+
+
+def test_get_top_results_keep_results():
+    fake_outputs = {"output_0": np.array([[1, 2, 3, 4], [5, 6, 7, 8]])}
+    number_of_results_wanted = 3
+    sut = tvmc.runner.get_top_results(fake_outputs, number_of_results_wanted)
+
+    expected_number_of_lines = 2
+    assert len(sut) == expected_number_of_lines
+
+    expected_number_of_results_per_line = 3
+    assert len(sut[0]) == expected_number_of_results_per_line
+    assert len(sut[1]) == expected_number_of_results_per_line
+
+
+def test_run_tflite_module__with_profile__valid_input(

Review comment:
       why there are many function names using double underscore?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to