Skip to content

Commit e5109db

Browse files
author
Christian Convey
committed
[hexagon][testing] add max_pool2d benchmark
- Add benchmarking framework for Hexagon maxpool-2d kernels, and one (simple) kernel. - Minor refactor hexagon benchmark utilities.
1 parent d92a773 commit e5109db

File tree

3 files changed

+406
-9
lines changed

3 files changed

+406
-9
lines changed

tests/python/contrib/test_hexagon/benchmark_elemwise_add.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from tvm.script import tir as T
2929
from tvm import te
3030
from tvm.contrib.hexagon.build import HexagonLauncherRPC
31-
from . import benchmark_util
31+
from . import benchmark_util as bu
3232

3333
# This is a fixed detail of the v68 architecture.
3434
HVX_VECTOR_BYTES = 128
@@ -43,7 +43,7 @@
4343
# triggering TIME_WAIT state on the server socket. This prevents another
4444
# server to bind to the same port until the wait time elapses.
4545

46-
_BT = benchmark_util.BenchmarksTable()
46+
_BT = bu.BenchmarksTable()
4747

4848
_CSV_COLUMN_ORDER = [
4949
# Identifies which TE-compute / TIRScript is used as the basis for the
@@ -129,7 +129,7 @@ def _get_irmod_elemwise_add(
129129
dtype_str = str(dtype)
130130

131131
if mem_scope == "global.vtcm":
132-
raise UnsupportedException("This benchmark kernel does not yet support VTCM buffers.")
132+
raise bu.UnsupportedException("This benchmark kernel does not yet support VTCM buffers.")
133133

134134
# This check is currently elided by the one above, but it should become relevant as soon
135135
# as we add VTCM support to this kernel generator.
@@ -147,7 +147,7 @@ def _get_irmod_elemwise_add(
147147
estimated_vtcm_needed_bytes = shape[0] * shape[1] * dtype_bytes * num_vtcm_tensors
148148

149149
if estimated_vtcm_needed_bytes > estimated_vtcm_budget_bytes:
150-
raise UnsupportedException("Expect to exceed VTCM budget.")
150+
raise bu.UnsupportedException("Expect to exceed VTCM budget.")
151151

152152
@tvm.script.ir_module
153153
class BenchmarkModule:
@@ -190,10 +190,10 @@ def _benchmark_hexagon_elementwise_add_kernel(
190190
"mem_scope": mem_scope,
191191
}
192192

193-
desc = benchmark_util.get_benchmark_decription(keys_dict)
193+
desc = bu.get_benchmark_decription(keys_dict)
194194

195195
# Create the host-side directory for this benchmark run's files / logs...
196-
host_files_dir_name = benchmark_util.get_benchmark_id(keys_dict)
196+
host_files_dir_name = bu.get_benchmark_id(keys_dict)
197197
host_files_dir_path = os.path.join(_HOST_OUTPUT_DIR, host_files_dir_name)
198198
os.mkdir(host_files_dir_path)
199199

@@ -296,11 +296,11 @@ def _benchmark_hexagon_elementwise_add_kernel(
296296
result, host_numpy_C_data_expected, rel_tolerance, abs_tolerance
297297
)
298298
except AssertionError as e:
299-
raise NumericalAccuracyException(str(e))
299+
raise bu.NumericalAccuracyException(str(e))
300300

301301
_BT.record_success(timing_result, **keys_dict)
302302

303-
except NumericalAccuracyException as e:
303+
except bu.NumericalAccuracyException as e:
304304
print()
305305
print(f"FAIL: Numerical accuracy error. See log file.")
306306

@@ -309,7 +309,7 @@ def _benchmark_hexagon_elementwise_add_kernel(
309309

310310
_BT.record_fail(**keys_dict, comments=f"Numerical accuracy error. See log file.")
311311

312-
except UnsupportedException as e:
312+
except bu.UnsupportedException as e:
313313
print()
314314
print(f"SKIP: {e}")
315315

0 commit comments

Comments
 (0)