From b045a8f082dde3cf503e8bb8146cf60c028bbbcc Mon Sep 17 00:00:00 2001 From: Max Bergfelt Date: Fri, 25 Jul 2025 09:09:13 +0200 Subject: [PATCH] MLBEDSW-11002: Added TOSA reader validation for RESCALE input rank 0 Added validation of input tensor ranks to the TOSA reader to catch and throw an error on RESCALE input rank 0 tensors when the attribute per channel is set. Change-Id: I94f781f0e37f0400115a66d76f494d6e3f1cff96 Signed-off-by: Max Bergfelt --- ethosu/regor/tosa/tosa_reader.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ethosu/regor/tosa/tosa_reader.cpp b/ethosu/regor/tosa/tosa_reader.cpp index 4c15079d..6c91a50a 100644 --- a/ethosu/regor/tosa/tosa_reader.cpp +++ b/ethosu/regor/tosa/tosa_reader.cpp @@ -743,6 +743,14 @@ void TosaReader::LoadGraphs(const tosaFb::TosaGraph *model, std::listSet(op, GraphApi::OpAttr::RESCALE_OUTPUT_UNSIGNED, tosa_attr.output_unsigned()), "Failed to set RESCALE_OUTPUT_UNSIGNED attribute on RESCALE"); + + if ( tosa_attr.per_channel() ) + { + const auto &rescaleInputTensor = input_tensors[0]; + tosa_assert(shapes.at(rescaleInputTensor).count != 0, + fmt::format("RESCALE input tensor {} needs to have rank > 0 when per channel attribute is set.", rescaleInputTensor) + .c_str()); + } } break; case tosaFb::Op::RESIZE: -- GitLab