Skip to content

Commit 8241d86

Browse files
committed
Arm backend: Move down main section in analyze_output_utils.py
The main section of a python file should be at the bottom to ensure everything from the file itself has been defined before running it. Signed-off-by: Martin Lindström <Martin.Lindstroem@arm.com> Change-Id: Ia534109ff87c9966641a9932c9fff8f6de5050fc
1 parent 569cf41 commit 8241d86

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

backends/arm/test/tester/analyze_output_utils.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -337,22 +337,6 @@ def dump_error_output(
337337
logger.error(f"{atol=}, {rtol=}, {qtol=}")
338338

339339

340-
if __name__ == "__main__":
341-
"""This is expected to produce the example output of print_diff."""
342-
torch.manual_seed(0)
343-
a = torch.rand(3, 3, 2, 2) * 0.01
344-
b = a.clone().detach()
345-
logger.info(b)
346-
347-
# Errors in all channels in element (1,1)
348-
a[1, :, 1, 1] = 0
349-
# Errors in (0,0) and (1,1) in channel 1
350-
a[2, 1, 1, 1] = 0
351-
a[2, 1, 0, 0] = 0
352-
353-
print_error_diffs(a, b)
354-
355-
356340
def compare_rel_frobenius_and_cosine_similarity(
357341
reference_output: torch.Tensor,
358342
test_output: torch.Tensor,
@@ -452,3 +436,19 @@ def compare_rel_frobenius_and_cosine_similarity(
452436
f"Tensor-wise comparison failed: Cosine similarity {cosine_similarity} is below threshold {cosine_threshold}."
453437
f" (Relative frobenius error: {relative_frobenius_error}, threshold {frobenius_threshold})."
454438
)
439+
440+
441+
if __name__ == "__main__":
442+
"""This is expected to produce the example output of print_diff."""
443+
torch.manual_seed(0)
444+
a = torch.rand(3, 3, 2, 2) * 0.01
445+
b = a.clone().detach()
446+
logger.info(b)
447+
448+
# Errors in all channels in element (1,1)
449+
a[1, :, 1, 1] = 0
450+
# Errors in (0,0) and (1,1) in channel 1
451+
a[2, 1, 1, 1] = 0
452+
a[2, 1, 0, 0] = 0
453+
454+
print_error_diffs(a, b)

0 commit comments

Comments
 (0)