From 2c1ff9687d602e50a8926eb473147490e8953ca4 Mon Sep 17 00:00:00 2001 From: Alexander Bengtsson Date: Tue, 8 Apr 2025 14:01:26 +0200 Subject: [PATCH] MLBEDSW-10658: Fix Decompose-hints for TransposeConv and Conv3D TransposeConv2D and Conv3D are legalized in scheduler_decompose. This requires scheduler-decomposition to run even if there are no out-of-range attributes. return decomposition-hints from archQuery if those opTypes are queried. Change-Id: Ibdfba0b3052b86f4bd4ee81d4174eaa367645e48 Signed-off-by: Alexander Bengtsson --- .../architecture/ethosu55/ethos_u55_constraints.cpp | 12 +++++++++++- .../architecture/ethosu85/ethos_u85_constraints.cpp | 12 +++++++++++- ethosu/regor/compiler/scheduler_decompose.cpp | 1 - 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp index 03fd3d7b..37933d51 100644 --- a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp +++ b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp @@ -279,13 +279,23 @@ Flags EthosU55Constraints::OperatorQuery(OpType opType, const ArchO { if ( req ) { - req->req = ArchRequirement::OpSubstitution; + req->req.Set(ArchRequirement::OpSubstitution); req->substitution = OpType::LUT; } result.Set(QueryResult::HasRequirements); } } + // TransposeConv2D and Conv3D are legalized during decomposition + if ( opType == OpType::TransposeConv2D || opType == OpType::Conv3D ) + { + if ( req ) + { + req->req.Set(ArchRequirement::Decompose); + } + return QueryResult::NativeConstrainedHasReq; + } + // Check direct native support of the opType auto npuOp = _arch->GetHWOp(opType); if ( npuOp == EthosU55NpuOp::None ) diff --git a/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp b/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp index 8a2ea87c..a7bc9315 100644 --- a/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp +++ b/ethosu/regor/architecture/ethosu85/ethos_u85_constraints.cpp @@ -262,12 +262,22 @@ Flags EthosU85Constraints::OperatorQuery(OpType opType, const ArchO { if ( req ) { - req->req = ArchRequirement::OpSubstitution; + req->req.Set(ArchRequirement::OpSubstitution); req->substitution = OpType::LUT; } result.Set(QueryResult::HasRequirements); } + // TransposeConv2D and Conv3D are legalized during decomposition + if ( opType == OpType::TransposeConv2D || opType == OpType::Conv3D ) + { + if ( req ) + { + req->req.Set(ArchRequirement::Decompose); + } + return QueryResult::NativeConstrainedHasReq; + } + // Check direct native support of the opType auto npuOp = _arch->GetHWOp(opType); if ( npuOp == EthosU85NpuOp::None ) diff --git a/ethosu/regor/compiler/scheduler_decompose.cpp b/ethosu/regor/compiler/scheduler_decompose.cpp index 836f590d..a5b91100 100644 --- a/ethosu/regor/compiler/scheduler_decompose.cpp +++ b/ethosu/regor/compiler/scheduler_decompose.cpp @@ -211,7 +211,6 @@ bool NeedsDecompose(Architecture *arch, const SchedulerOperation *schedOp) ArchRequirements req{}; Flags result = OperatorQuery(arch, schedOp, &req); // Assert complete query - assert(result.Any(QueryResult::Constrained) == false && "Constrained result from complete OperatorQuery"); if ( result.Any(QueryResult::Unsupported) ) { // Operations completely unsupported by HW should not be decomposed -- GitLab