diff --git a/test/common/compare.cpp b/test/common/compare.cpp index b2c58fc17d3cb2470cdc33caa56c5da8a77a1a4e..29d96493f4e2c8c112d078885d9ffac522e270a7 100644 --- a/test/common/compare.cpp +++ b/test/common/compare.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -50,13 +51,17 @@ template bool compare_raw( const void* imp_data, const void* ref_data, const DataFormat& format, size_t full_height, size_t full_width, const Rect& rect, MismatchHandler& handler) { - const auto block_height = format.actual_block_height(full_height); - const auto block_width = format.actual_block_width(full_width); - const auto subblock_height = format.actual_subblock_height(full_height); - const auto subblock_width = format.actual_subblock_width(full_width); + const size_t block_height = format.actual_block_height(full_height); + const size_t block_width = format.actual_block_width(full_width); + const size_t subblock_height = format.actual_subblock_height(full_height); + const size_t subblock_width = format.actual_subblock_width(full_width); size_t idx = 0; + bool block_heading_written = false; + bool subblock_heading_written = false; + bool row_heading_written = false; + std::ostringstream sstream; for (size_t y_block = 0; y_block < full_height; y_block += block_height) { for (size_t x_block = 0; x_block < full_width; x_block += block_width) { for (size_t y_subblock = 0; y_subblock < block_height; y_subblock += subblock_height) { @@ -76,21 +81,41 @@ bool compare_raw( const auto notifying = !in_roi || handler.handle_data(abs_err, rel_err); if (notifying) { - KAI_LOGE( - "Mismatched data at (", y, ", ", x, "): actual = ", imp_value, - ", expected: ", ref_value); + if (!block_heading_written) { + sstream << "block @ (" << y_block << ", " << x_block << "):\n"; + block_heading_written = true; + } + if (!subblock_heading_written) { + sstream << " sub-block @ (" << y_subblock << ", " << x_subblock << "):\n"; + subblock_heading_written = true; + } + if (!row_heading_written) { + sstream << " row=" << y_element << ": "; + row_heading_written = true; + } + sstream << x_element << ", "; } } ++idx; } + if (row_heading_written) { + sstream << "\n"; + } + row_heading_written = false; } + subblock_heading_written = false; } } + block_heading_written = false; } } - return handler.success(full_height * full_width); + const bool success = handler.success(full_height * full_width); + if (!success) { + KAI_LOGE("mismatches:\n", sstream.str()); + } + return success; } /// Compares matrices with per-row bias or per-row quantization. diff --git a/test/common/matmul_test_common.cpp b/test/common/matmul_test_common.cpp index 67b05d0b5588f7004c8d07959232b49ec4fb007e..91853deaf136c83898a54e231ef26d0c5da50d6a 100644 --- a/test/common/matmul_test_common.cpp +++ b/test/common/matmul_test_common.cpp @@ -6,9 +6,15 @@ #include "matmul_test_common.hpp" +#include #include namespace kai::test { + +std::ostream& operator<<(std::ostream& os, const MatMulShape& shape) { + return os << "[m=" << shape.m << ", n=" << shape.n << ", k=" << shape.k << "]"; +} + void PrintTo(const MatMulTestParams& param, std::ostream* os) { const auto& [method, shape, portion] = param; diff --git a/test/common/matmul_test_common.hpp b/test/common/matmul_test_common.hpp index 3db8b8113c19bb65a4eb9c1601e61baeee92a244..030f17875a91af041733516fd756e4b876c210a6 100644 --- a/test/common/matmul_test_common.hpp +++ b/test/common/matmul_test_common.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ private: lhs.n == rhs.n && // lhs.k == rhs.k; } + friend std::ostream& operator<<(std::ostream& os, const MatMulShape& shape); }; /// Value range diff --git a/test/reference/quantize.cpp b/test/reference/quantize.cpp index 025f677bb28c0d84942f82051167e87095086bc6..7a2fb198f78f5da474ec419eccf5c09e239f7fd6 100644 --- a/test/reference/quantize.cpp +++ b/test/reference/quantize.cpp @@ -84,6 +84,8 @@ std::vector compute_symmetric_per_block_quantization_info( static_assert(is_integral); static_assert(is_floating_point); + KAI_ASSUME(quant_width != 0); + const auto num_quant_packets_x = round_up_division(width, quant_width); const auto scales_bytes = height * num_quant_packets_x * sizeof(ScaleType); @@ -189,6 +191,8 @@ std::tuple, std::vector> compute_asymmetric_per_bl static_assert(is_floating_point); static_assert(is_integral); + KAI_ASSUME(quant_width != 0); + const auto num_quant_packets_x = round_up_division(width, quant_width); const auto scales_bytes = height * num_quant_packets_x * sizeof(ScaleType); diff --git a/test/reference/reduce.hpp b/test/reference/reduce.hpp index a3ccec7c72a28f17e3b7f74c9120f40712ce5c5f..449dc57ff694587224f1f449d623227252421233 100644 --- a/test/reference/reduce.hpp +++ b/test/reference/reduce.hpp @@ -1,5 +1,5 @@ // -// SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates +// SPDX-FileCopyrightText: Copyright 2024-2025 Arm Limited and/or its affiliates // // SPDX-License-Identifier: Apache-2.0 // @@ -25,7 +25,7 @@ enum class ReductionOperator : uint32_t { /// @param[in] src_format Input data format. /// @param[in] height Number of rows. /// @param[in] width Number of columns. -/// @param[in] dst_foramt Output data format. +/// @param[in] dst_format Output data format. /// @param[in] dimension Reduction dimension. /// /// @return The reduced matrix.