Merge pull request #28750 from abhishek-gola:activation_fusion

Extended fusion for activation functions in new DNN engine #28750

After this fusion, we see following improvements in YOLO models:

| Model | Before (`ENGINE_NEW`) | After (`ENGINE_NEW`) | `ENGINE_ORT` | % Improvement (Before v/s After) |
| :--- | :--- | :--- | :--- | :--- |
| **YOLOv8n** | 18.89  ms| 12.06 ms| 12.15 ms| 36.16% |
| **YOLOv5n** | 17.12  ms| 9.29 ms| 9.23 ms| 45.73% |
| **YOLOX-S** | 38.78  ms| 25.56 ms| 25.16 ms| 34.09% |

Device details: 
      - Model name: Intel(R) Core(TM) i9-14900KS, x86, 32 Cores, ubuntu 24.04,
### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Abhishek Gola
2026-04-14 11:38:14 +05:30
committed by GitHub
parent 53d9a67cf3
commit 3d77645a3a
13 changed files with 561 additions and 23 deletions

View File

@@ -2389,6 +2389,15 @@ public:
activationParams.set("scale", 0.3f);
activationParams.set("shift", 0.6f);
}
else if (activationParams.type == "ELU")
{
activationParams.set("alpha", 1.0f);
}
else if (activationParams.type == "HardSigmoid")
{
activationParams.set("alpha", 0.2f);
activationParams.set("beta", 0.5f);
}
}
static void makeDefaultTestEltwiseLayer(LayerParams& eltwiseParams, const std::string& op, bool withCoefficients)
@@ -2460,7 +2469,8 @@ public:
static testing::internal::ParamGenerator<std::string> activationLayersList()
{
// TODO: automate list generation
return Values("ReLU", "ReLU6", "ChannelsPReLU", "TanH", "Swish", "Mish", "Sigmoid", "ELU", "AbsVal", "BNLL", "Power", "Exp");
return Values("ReLU", "ReLU6", "ChannelsPReLU", "TanH", "Swish", "Mish", "Sigmoid", "ELU",
"AbsVal", "BNLL", "Power", "Exp", "HardSwish", "HardSigmoid", "Gelu", "GeluApproximation");
}
static testing::internal::ParamGenerator<tuple<Backend, Target> > dnnBackendsAndTargetsForFusionTests()