-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
DNN: Adding Eltwise (-) layer support #17187
Description
System information (version)
- OpenCV =>4.3
- Operating System / Platform => RedHat 7 64 Bit and Window 10
- Compiler => GCC 4.8.5 and Visual Studio 2015
Detailed description
Can Eltwise (-) support be added to the onnx importer? I've noticed that going from AlexNet Opset 6 to Opset 7 (generated from Matlab 2019) the very first layer ("data_Sub") changed from a "scale" operation to "eltwise (-)". I've seen on the support page for OpenCV that Eltwise (-) is not listed as a supported layer feature. What happens here is the the onnx importer defaults to Eltwise (+) which doesn't give us activation numbers that match our Matlab numbers
I made a change to the onnx_importer::populateNet (line 555)
constParams.blobs.push_back(blob);to
constParams.blobs.push_back((isSub ? -1 : 1) * blob);This seems to fix the issue for us and now OpenCVs activation numbers and inference match our MATLAB results. This seems like a relatively easy way to add Eltwise (-) support. However, being new to OpenCV I don't know the potential ramifications.
Sorry for the cross-post but I submitted here as well:
https://answers.opencv.org/question/229405/alexnet-opset6-to-opset7-eltwise-change
Steps to reproduce
Use OpenCV to run inference on an image using AlexNet Opset6
Forward network to just the "data_Sub" layer
Examine activation numbers
Use OpenCV to run inference on an image using AlexNet Opset 7
Forward network to just the "data_Sub" layer
Compare activation number between Opsets and you can see it defaults to addition