MCPcopy Index your code
hub / github.com/apache/tvm / test_min_repeat_ms

Function test_min_repeat_ms

tests/python/runtime/test_runtime_measure.py:27–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25
26
27def test_min_repeat_ms():
28 tmp = tempdir()
29 filename = tmp.relpath("log")
30
31 @tvm.register_global_func
32 def my_debug(filename):
33 """one call lasts for 100 ms and writes one character to a file"""
34 time.sleep(0.1)
35 with open(filename, "a") as fout:
36 fout.write("c")
37
38 X = te.compute((), lambda: tvm.tirx.call_packed("my_debug", filename))
39 func = tvm.tirx.build(te.create_prim_func([X]))
40
41 x = tvm.runtime.empty((), dtype="int32")
42 ftimer = func.time_evaluator(func.entry_name, tvm.cpu(), number=1, repeat=1)
43 ftimer(x)
44
45 with open(filename) as fin:
46 ct = len(fin.readline())
47
48 assert ct == 2
49
50 ftimer = func.time_evaluator(func.entry_name, tvm.cpu(), number=1, repeat=1, min_repeat_ms=1000)
51 ftimer(x)
52
53 # make sure we get more than 10 calls
54 with open(filename) as fin:
55 ct = len(fin.readline())
56
57 assert ct > 10 + 2
58
59
60def test_benchmark_result():

Callers 1

Calls 7

tempdirFunction · 0.90
relpathMethod · 0.80
call_packedMethod · 0.80
buildMethod · 0.45
emptyMethod · 0.45
time_evaluatorMethod · 0.45
cpuMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…