From 4472430d58f184e7b8be84690be62f4a31ac3f82 Mon Sep 17 00:00:00 2001 From: Rickard Bolin Date: Wed, 30 Apr 2025 08:19:41 +0000 Subject: [PATCH] MLBEDSW-10631: Modify CONST error check CONST operator error check assumed exact size match between buffer and OFM tensor storage size bytes. That failed since TOSA tensors are 8 byte aligned. Changed to check that buffer has enough elements to fill OFM instead. Change-Id: Ice7ddc04707d81e27f5f26317ab12fe5640008d9 Signed-off-by: Rickard Bolin --- ethosu/regor/tosa/tosa_error_checks.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ethosu/regor/tosa/tosa_error_checks.cpp b/ethosu/regor/tosa/tosa_error_checks.cpp index 26a24b7c..20b989e3 100644 --- a/ethosu/regor/tosa/tosa_error_checks.cpp +++ b/ethosu/regor/tosa/tosa_error_checks.cpp @@ -1519,11 +1519,15 @@ void ErrorIfCheck_396rg8p65j58r(const regor::Operation *op, [[maybe_unused]] con void ErrorIfCheck_3oet4aggtv528(const regor::Operation *op, [[maybe_unused]] const Context &context) { // Operators: CONST, + // Would ideally check that the shape of the attibute "values" matches output shape, but that has already been + // read in to the OFM buffer so no tensor exists. Instead, check that buffer has enough elements for the ofm. static constexpr char constraint[] = "ERROR_IF(rankCheck(output, values))"; const auto &ofmConn = op->Output(TensorUsage::OFM); const auto bufferSize = ofmConn->tensor->View().Buffer()->Size(); const auto storageSize = DataTypeStorageSizeBytes(ofmConn->tensor->Type(), ofmConn->shape.Elements()); - if ( bufferSize != storageSize ) throw std::invalid_argument(constraint); + // TOSA tensors align to 8 bytes so can't check exact size + // Instead, check that buffer is big enough to fill the OFM + if ( bufferSize < storageSize ) throw std::invalid_argument(constraint); } } // namespace checks -- GitLab