From 81e1b04e3840365602bb515a388557254f0cb76e Mon Sep 17 00:00:00 2001 From: Philip Hall Date: Wed, 12 Feb 2025 16:29:15 +0000 Subject: [PATCH] MLBEDSW-10421: Avoid HLC ordering assert by ordered insertion The HLC op's ifm list is better created by inserting the ifm's in the correct order; rather than asserting that the originating order was incorrect. Signed-off-by: Philip Hall Change-Id: Idb737bd2418d921e94198a81a53d322365dae7e6 --- .../high_level_command_stream_generator.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ethosu/regor/compiler/high_level_command_stream_generator.cpp b/ethosu/regor/compiler/high_level_command_stream_generator.cpp index 4eb673c6..d5c5a2ad 100644 --- a/ethosu/regor/compiler/high_level_command_stream_generator.cpp +++ b/ethosu/regor/compiler/high_level_command_stream_generator.cpp @@ -287,11 +287,12 @@ static HLCSubOperation MakeSubOperation(const std::unique_ptrinputs.pairs() ) { + std::vector::iterator at; if ( IsIFM(input.first) ) { - assert(((input.first == TensorUsage::IFM0) && hlcSubOp.ifm.empty()) || !hlcSubOp.ifm.empty()); - hlcSubOp.ifm.emplace_back(); - MakeFeatureMap(input.first, &input.second, hlcSubOp.ifm.back()); + at = hlcSubOp.ifm.emplace(std::upper_bound(hlcSubOp.ifm.begin(), hlcSubOp.ifm.end(), input.first, + [](TensorUsage usage, const HLCFeatureMap &fm) { return usage < fm.usage; })); + MakeFeatureMap(input.first, &input.second, *at); } } MakeFeatureMap(TensorUsage::OFM, schedOp->OFM(), hlcSubOp.ofm); @@ -325,11 +326,12 @@ static std::shared_ptr MakeOperation(SchedulerOperation *schedOp, for ( const auto &input : schedOp->inputs.pairs() ) { + std::vector::iterator at; if ( IsIFM(input.first) ) { - assert(((input.first == TensorUsage::IFM0) && op->ifm.empty()) || !op->ifm.empty()); // map not in order - op->ifm.emplace_back(); - MakeFeatureMap(input.first, &input.second, op->ifm.back()); + at = op->ifm.emplace(std::upper_bound(op->ifm.begin(), op->ifm.end(), input.first, + [](TensorUsage usage, const HLCFeatureMap &fm) { return usage < fm.usage; })); + MakeFeatureMap(input.first, &input.second, *at); } } MakeFeatureMap(TensorUsage::OFM, schedOp->OFM(), op->ofm); -- GitLab