Skip to content

Commit 4192fec

Browse files
Make Tester check shapes of reference and model output (#7589)
Make Tester check shapes of ref and model output torch.allclose() will broadcast data if neccessary. This means that Tester.run_method_and_compare_outputs() may pass even though a delegate produced an output of wrong shape. Change-Id: If62907e0fc69cc28b1f5ce5f8cfd6f31b1870a1e Signed-off-by: Oscar Andersson <[email protected]>
1 parent a059981 commit 4192fec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

backends/xnnpack/test/tester/tester.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# Copyright 2025 Arm Limited and/or its affiliates.
23
# All rights reserved.
34
#
45
# This source code is licensed under the BSD-style license found in the
@@ -679,6 +680,9 @@ def _assert_outputs_equal(model_output, ref_output, atol=1e-03, rtol=1e-03):
679680
for i in range(len(model_output)):
680681
model = model_output[i]
681682
ref = ref_output[i]
683+
assert (
684+
ref.shape == model.shape
685+
), f"Output {i} shape {model.shape} does not match reference output shape {ref.shape}"
682686
assert torch.allclose(
683687
model,
684688
ref,

0 commit comments

Comments
 (0)