MCPcopy Create free account
hub / github.com/apache/tvm / BenchmarkResult

Class BenchmarkResult

python/tvm/runtime/module.py:48–104  ·  view source on GitHub ↗

Runtimes from benchmarking

Source from the content-addressed store, hash-verified

46
47
48class BenchmarkResult:
49 """Runtimes from benchmarking"""
50
51 def __init__(self, results: Sequence[float]):
52 """Construct a new BenchmarkResult from a sequence of runtimes.
53
54 Parameters
55 ----------
56 results : Sequence[float]
57 Raw times from benchmarking
58
59 Attributes
60 ----------
61 min : float
62 Minimum runtime in seconds of all results.
63 mean : float
64 Mean runtime in seconds of all results. If py:meth:`Module.time_evaluator` or
65 `benchmark` is called with `number` > 0, then each result is already the mean of a
66 `number` of runtimes, so this becomes the mean of means.
67 median : float
68 Median runtime in seconds of all results. If py:meth:`Module.time_evaluator` is called
69 with `number` > 0, then each result is already the mean of a `number` of runtimes, so
70 this becomes the median of means.
71 max : float
72 Maximum runtime in seconds of all results. If py:meth:`Module.time_evaluator` is called
73 with `number` > 0, then each result is already the mean of a `number` of runtimes, so
74 this becomes the maximum of those means.
75 std : float
76 Standard deviation in seconds of runtimes. If py:meth:`Module.time_evaluator` is called
77 with `number` > 0, then each result is already the mean of a `number` of runtimes, so
78 this becomes the standard deviation of means.
79 results : Sequence[float]
80 The collected runtimes (in seconds). This may be a series of mean runtimes if
81 py:meth:`Module.time_evaluator` or `benchmark` was run with `number` > 1.
82 """
83 self.results = results
84 self.mean = np.mean(self.results)
85 self.std = np.std(self.results)
86 self.median = np.median(self.results)
87 self.min = np.min(self.results)
88 self.max = np.max(self.results)
89
90 def __repr__(self):
91 return (
92 f"BenchmarkResult(min={self.min}, mean={self.mean}, median={self.median}, "
93 f"max={self.max}, std={self.std}, results={self.results})"
94 )
95
96 def __str__(self):
97 return (
98 f"Execution time summary:\n"
99 f"{'mean (ms)':^12} {'median (ms)':^12} {'max (ms)':^12} "
100 f"{'min (ms)':^12} {'std (ms)':^12}\n"
101 f"{self.mean * 1000:^12.4f} {self.median * 1000:^12.4f} {self.max * 1000:^12.4f} "
102 f"{self.min * 1000:^12.4f} {self.std * 1000:^12.4f}"
103 " "
104 )
105

Callers 2

test_benchmark_resultFunction · 0.90
evaluatorMethod · 0.85

Calls

no outgoing calls

Tested by 1

test_benchmark_resultFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…