()
| 25 | |
| 26 | |
| 27 | def 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 | |
| 60 | def test_benchmark_result(): |
no test coverage detected
searching dependent graphs…