diff --git a/ethosu/regor/tflite/tflite_supported_operators.cpp b/ethosu/regor/tflite/tflite_supported_operators.cpp index 4b030ae944410108b5e069400940ec0836086fb0..10643b9f298a36aa1c42bd98ccb18dc77fec0f5d 100644 --- a/ethosu/regor/tflite/tflite_supported_operators.cpp +++ b/ethosu/regor/tflite/tflite_supported_operators.cpp @@ -702,6 +702,25 @@ bool TfLiteSupportedOperators::ConstraintMean(const Operation *op) return true; } +bool TfLiteSupportedOperators::ConstraintSoftmax(const Operation *op) +{ + OpType opType = op->Type(); + if ( opType != OpType::Softmax ) + { + return true; + } + auto ifmConn = op->Input(TensorUsage::IFM); + assert(ifmConn); + static constexpr int maxProd = 1 << 16; + const auto &ifmShape = ifmConn->shape; + if ( ifmShape.ElementsWH() > maxProd ) + { + Failure(op, fmt::format("ifmShape: ({}), W * H = {}", ifmShape.ToString(), ifmShape.ElementsWH()), + "The product of IFM width and height must be less than 65536"); + return false; + } + return true; +} void TfLiteSupportedOperators::Failure(const Operation *op, const std::string &message, const std::string &constraint) { @@ -752,6 +771,7 @@ TfLiteSupportedOperators::TfLiteSupportedOperators(IArchitectureConstraints *con &TfLiteSupportedOperators::ConstraintRsqrt, &TfLiteSupportedOperators::ConstraintConstParams, &TfLiteSupportedOperators::ConstraintMean, + &TfLiteSupportedOperators::ConstraintSoftmax, }; } diff --git a/ethosu/regor/tflite/tflite_supported_operators.hpp b/ethosu/regor/tflite/tflite_supported_operators.hpp index 06b5de7912665b655825e9b7f872014db31f1f3e..92552e418834f0946ed1a3e11fac8fecfa4f0c4d 100644 --- a/ethosu/regor/tflite/tflite_supported_operators.hpp +++ b/ethosu/regor/tflite/tflite_supported_operators.hpp @@ -70,5 +70,6 @@ private: bool ConstraintRsqrt(const Operation *op); bool ConstraintConstParams(const Operation *op); bool ConstraintMean(const Operation *op); + bool ConstraintSoftmax(const Operation *op); }; } // namespace regor