mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 01:13:28 +08:00
Merge pull request #24709 from vpisarev:winograd_mode
Try to enable Winograd by default in FP32 mode and disable it by default in FP16 mode #24709 Hopefully, it will resolve regressions since 4.8.1 (see also https://github.com/opencv/opencv/pull/24587) ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [ ] I agree to contribute to the project under Apache 2 License. - [ ] 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 - [ ] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
35e2ef8019
commit
853e5dfcdf
@ -291,7 +291,7 @@ CV__DNN_INLINE_NS_BEGIN
|
||||
static Ptr<BaseConvolutionLayer> create(const LayerParams& params);
|
||||
bool fusedActivation = false;
|
||||
bool fusedAdd = false;
|
||||
bool useWinograd = false; // Flag whether to use Winograd to speed up 3x3 convolution.
|
||||
bool useWinograd = true; // Flag whether to use Winograd to speed up 3x3 convolution.
|
||||
};
|
||||
|
||||
class CV_EXPORTS ConvolutionLayerInt8 : public BaseConvolutionLayer
|
||||
|
@ -195,7 +195,7 @@ void getConvolutionKernelParams(const LayerParams ¶ms, std::vector<size_t>&
|
||||
util::getStrideAndPadding(params, pads_begin, pads_end, strides, padMode, kernel.size());
|
||||
util::getParameter(params, "dilation", "dilation", dilations, true, std::vector<size_t>(kernel.size(), 1));
|
||||
util::getParameter(params, "adj", "adj", adjust_pads, true, std::vector<size_t>(kernel.size(), 0));
|
||||
useWinograd = params.get<bool>("use_winograd", true);
|
||||
useWinograd = params.get<bool>("use_winograd", useWinograd);
|
||||
|
||||
for (int i = 0; i < dilations.size(); i++)
|
||||
CV_Assert(dilations[i] > 0);
|
||||
|
@ -251,6 +251,14 @@ void Net::Impl::setPreferableTarget(int targetId)
|
||||
#endif
|
||||
|
||||
clear();
|
||||
|
||||
if (targetId == DNN_TARGET_CPU_FP16)
|
||||
{
|
||||
if (useWinograd) {
|
||||
CV_LOG_INFO(NULL, "DNN: DNN_TARGET_CPU_FP16 is set => Winograd convolution is disabled by default to preserve accuracy. If needed, enable it explicitly using enableWinograd(true).");
|
||||
enableWinograd(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user