From 9399721043c05eb327ba5c1e236fe09ae2cfed16 Mon Sep 17 00:00:00 2001 From: Oscar Andersson Date: Wed, 18 Dec 2024 16:27:06 +0100 Subject: [PATCH] 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. Signed-off-by: Oscar Andersson Change-Id: If62907e0fc69cc28b1f5ce5f8cfd6f31b1870a1e --- backends/xnnpack/test/tester/tester.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backends/xnnpack/test/tester/tester.py b/backends/xnnpack/test/tester/tester.py index 1b6f03512bd..d6e2f12884a 100644 --- a/backends/xnnpack/test/tester/tester.py +++ b/backends/xnnpack/test/tester/tester.py @@ -1,4 +1,5 @@ # Copyright (c) Meta Platforms, Inc. and affiliates. +# Copyright 2025 Arm Limited and/or its affiliates. # All rights reserved. # # 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): for i in range(len(model_output)): model = model_output[i] ref = ref_output[i] + assert ( + ref.shape == model.shape + ), f"Output {i} shape {model.shape} does not match reference output shape {ref.shape}" assert torch.allclose( model, ref,