Skip to content

Commit

Permalink
Change output format to be more readable.
Browse files Browse the repository at this point in the history
  • Loading branch information
nverke committed Feb 15, 2023
1 parent c3e5ff7 commit 414d1b4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
34 changes: 18 additions & 16 deletions tests/python/contrib/test_hexagon/infrastructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,45 +479,47 @@ def evaluate_separated_layout_transform(
args = [a, ac]
if quants:
args.append(azp)
input_NCHW_to_tiled_module_runtime = input_NCHW_to_tiled_module_timer(*args).mean * 1000
input_NCHW_to_tiled_module_runtime = round(input_NCHW_to_tiled_module_timer(*args).mean * 1000, 4)
args = [w, wc]
filter_OIHW_to_tiled_module_runtime = filter_OIHW_to_tiled_module_timer(*args).mean * 1000
filter_OIHW_to_tiled_module_runtime = round(filter_OIHW_to_tiled_module_timer(*args).mean * 1000, 4)
if quants:
args = [wc, wb, sb, azp, rqis, rqizp, rqos, rqozp]
bias_filter_constexpr_module_runtime = bias_filter_constexpr_timer(*args).mean * 1000
bias_filter_constexpr_module_runtime = round(bias_filter_constexpr_timer(*args).mean * 1000, 4)
else:
bias_filter_constexpr_module_runtime = 0
args = [ac, bc, wc]
if quants:
args.extend([sb, azp])
main_module_runtime = main_module_module_timer(*args).mean * 1000
output_tiled_to_NCHW_module_runtime = output_tiled_to_NCHW_module_timer(b, bc).mean * 1000
total_runtime = (
main_module_runtime = round(main_module_module_timer(*args).mean * 1000, 4)
output_tiled_to_NCHW_module_runtime = round(output_tiled_to_NCHW_module_timer(b, bc).mean * 1000, 4)
total_runtime = round(
output_tiled_to_NCHW_module_runtime
+ main_module_runtime
+ filter_OIHW_to_tiled_module_runtime
+ bias_filter_constexpr_module_runtime
+ input_NCHW_to_tiled_module_runtime
+ input_NCHW_to_tiled_module_runtime, 4
)

N, OC, OH, OW = shapes["output_shape"]
_, IC, FH, FW = shapes["filter_shape"]
main_flops = (2 * IC * FH * FW * N * OH * OW * OC) / main_module_runtime

print("input_shape, filter_shape, total_runtime, input_NCHW_to_tiled_module_runtime, filter_OIHW_to_tiled_module_runtime, bias_filter_constexpr_module_runtime, main_module_runtime, output_tiled_to_NCHW_module_runtime")
print(
test_name,
input_activation.shape,
input_weights.shape,
headers = ["input_shape", "filter_shape", "total_runtime", "input->tiled", "filter->tiled", "bias", "main", "output->NCHW"]
data = [test_name,
str(input_activation.shape),
str(input_weights.shape),
total_runtime,
input_NCHW_to_tiled_module_runtime,
filter_OIHW_to_tiled_module_runtime,
bias_filter_constexpr_module_runtime,
main_module_runtime,
output_tiled_to_NCHW_module_runtime,
sep="|",
)
output_tiled_to_NCHW_module_runtime]

print("Main module GOP/s : ", main_flops / main_module_runtime / 1e6) # (1000 ms / s) / (1e9 ns / s)
row_format ="|{:>15}|" * (len(headers) + 1)
print(row_format.format("", *headers))
print(row_format.format(*data))
# for team, row in zip(headers, data):
# print(row_format.format(team, *row))

print("Main module GOP/s : ", main_flops / main_module_runtime / 1e6) # (1000 ms / s) / (1e9 ns / s)
numpy.testing.assert_allclose(reference_output, b.asnumpy(), atol=1e-4, rtol=1e-5)
2 changes: 1 addition & 1 deletion tests/python/contrib/test_hexagon/test_qnn_conv2d_hmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_no_layout_transforms(
input_weights,
output,
reference_output_quantized,
"test_conv2d_bias_requantize_separated_layout_async_lowered",
"test_conv2d",
mem_scope=mem_scope,
bias=input_bias,
quants=quantization_parameters,
Expand Down

0 comments on commit 414d1b4

Please sign in to comment.