diff --git a/modules/dnn/src/init.cpp b/modules/dnn/src/init.cpp index 2170aafc4b..e8450c18f9 100644 --- a/modules/dnn/src/init.cpp +++ b/modules/dnn/src/init.cpp @@ -212,6 +212,7 @@ void initializeLayerFactory() CV_DNN_REGISTER_LAYER_CLASS(SigmoidInt8, ActivationLayerInt8); CV_DNN_REGISTER_LAYER_CLASS(TanHInt8, ActivationLayerInt8); CV_DNN_REGISTER_LAYER_CLASS(SwishInt8, ActivationLayerInt8); + CV_DNN_REGISTER_LAYER_CLASS(HardSwishInt8, ActivationLayerInt8); CV_DNN_REGISTER_LAYER_CLASS(MishInt8, ActivationLayerInt8); CV_DNN_REGISTER_LAYER_CLASS(ELUInt8, ActivationLayerInt8); CV_DNN_REGISTER_LAYER_CLASS(BNLLInt8, ActivationLayerInt8); diff --git a/modules/dnn/src/int8layers/elementwise_layers.cpp b/modules/dnn/src/int8layers/elementwise_layers.cpp index 2f40a4039f..5c533840f3 100644 --- a/modules/dnn/src/int8layers/elementwise_layers.cpp +++ b/modules/dnn/src/int8layers/elementwise_layers.cpp @@ -267,6 +267,8 @@ public: res = std::make_shared(input, 1.0f); } else if (type == "MishInt8") { res = std::make_shared(input); + } else if (type == "HardSwishInt8") { + res = std::make_shared(input); } else if (type == "AbsValInt8") { res = std::make_shared(input); } else if (type == "SigmoidInt8") { diff --git a/modules/dnn/src/tflite/tflite_importer.cpp b/modules/dnn/src/tflite/tflite_importer.cpp index ed51b4461a..f0e1546306 100644 --- a/modules/dnn/src/tflite/tflite_importer.cpp +++ b/modules/dnn/src/tflite/tflite_importer.cpp @@ -939,6 +939,8 @@ void TFLiteImporter::parseActivation(const Operator& op, const std::string& opco y = std::min(std::max(x, 0.f), 6.f); else if (opcode == "LOGISTIC") y = 1.0f / (1.0f + std::exp(-x)); + else if (opcode == "HARD_SWISH") + y = x * max(0.f, min(1.f, x / 6.f + 0.5f)); else CV_Error(Error::StsNotImplemented, "Lookup table for " + opcode);