diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp index 0b6c0a6e3814c7127ab0a72646565818c3f6f193..03dff96464bb513226a95842909fcb52d7ab6cbd 100644 --- a/modules/dnn/src/caffe/caffe_importer.cpp +++ b/modules/dnn/src/caffe/caffe_importer.cpp @@ -53,6 +53,8 @@ #include "caffe_io.hpp" #endif +#include + namespace cv { namespace dnn { CV__DNN_EXPERIMENTAL_NS_BEGIN @@ -88,6 +90,8 @@ MatShape parseBlobShape(const caffe::BlobShape& _input_shape) class CaffeImporter { + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + caffe::NetParameter net; caffe::NetParameter netBinary; diff --git a/modules/dnn/src/darknet/darknet_importer.cpp b/modules/dnn/src/darknet/darknet_importer.cpp index 282b37277c50370607ef01dd46cdfa7e83d80e79..5d28dbd2e27ef89ce5167b48112ad5fc5721c555 100644 --- a/modules/dnn/src/darknet/darknet_importer.cpp +++ b/modules/dnn/src/darknet/darknet_importer.cpp @@ -51,6 +51,7 @@ #include "darknet_io.hpp" +#include namespace cv { namespace dnn { @@ -61,6 +62,8 @@ namespace class DarknetImporter { + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + darknet::NetParameter net; public: diff --git a/modules/dnn/src/dnn.cpp b/modules/dnn/src/dnn.cpp index 28bcde48270145a49672162384d1ca5c4c168a4b..52428a98982ec28aec9bc230863121d85352ca32 100644 --- a/modules/dnn/src/dnn.cpp +++ b/modules/dnn/src/dnn.cpp @@ -55,6 +55,8 @@ #include #include +#include + #include #include @@ -3504,6 +3506,9 @@ Net Net::readFromModelOptimizer(const String& xml, const String& bin) CV_UNUSED(xml); CV_UNUSED(bin); CV_Error(Error::StsError, "Build OpenCV with Inference Engine to enable loading models from Model Optimizer."); #else + + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + #if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R3) InferenceEngine::CNNNetReader reader; reader.ReadNetwork(xml); @@ -3540,6 +3545,8 @@ Net Net::readFromModelOptimizer( CV_Error(Error::StsError, "Build OpenCV with Inference Engine to enable loading models from Model Optimizer."); #else + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + #if INF_ENGINE_VER_MAJOR_LE(INF_ENGINE_RELEASE_2019R3) InferenceEngine::CNNNetReader reader; @@ -3639,6 +3646,7 @@ Mat Net::forward(const String& outputName) { CV_TRACE_FUNCTION(); CV_Assert(!empty()); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; String layerName = outputName; @@ -3660,6 +3668,7 @@ AsyncArray Net::forwardAsync(const String& outputName) { CV_TRACE_FUNCTION(); CV_Assert(!empty()); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; #ifdef CV_CXX11 String layerName = outputName; @@ -3691,6 +3700,7 @@ void Net::forward(OutputArrayOfArrays outputBlobs, const String& outputName) { CV_TRACE_FUNCTION(); CV_Assert(!empty()); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; String layerName = outputName; @@ -3769,6 +3779,7 @@ void Net::forward(OutputArrayOfArrays outputBlobs, const std::vector& outBlobNames) { CV_TRACE_FUNCTION(); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; std::vector pins; for (int i = 0; i < outBlobNames.size(); i++) @@ -3796,6 +3807,7 @@ void Net::forward(std::vector >& outputBlobs, const std::vector& outBlobNames) { CV_TRACE_FUNCTION(); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; std::vector pins; for (int i = 0; i < outBlobNames.size(); i++) @@ -3886,6 +3898,7 @@ void Net::setInput(InputArray blob, const String& name, double scalefactor, cons { CV_TRACE_FUNCTION(); CV_TRACE_ARG_VALUE(name, "name", name.c_str()); + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; LayerPin pin; pin.lid = 0; diff --git a/modules/dnn/src/layers/convolution_layer.cpp b/modules/dnn/src/layers/convolution_layer.cpp index f5c158453d79a0a05d61db6cbab02535f05d29e4..e160cfeebe8339ae700c093ae9594b1702e48677 100644 --- a/modules/dnn/src/layers/convolution_layer.cpp +++ b/modules/dnn/src/layers/convolution_layer.cpp @@ -1629,13 +1629,6 @@ public: CV_TRACE_FUNCTION(); CV_TRACE_ARG_VALUE(name, "name", name.c_str()); -#if CV_SSE3 - uint32_t ftzMode = _MM_GET_FLUSH_ZERO_MODE(); - uint32_t dazMode = _MM_GET_DENORMALS_ZERO_MODE(); - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); -#endif - CV_OCL_RUN(IS_DNN_OPENCL_TARGET(preferableTarget), forward_ocl(inputs_arr, outputs_arr, internals_arr)) @@ -1748,10 +1741,6 @@ public: ParallelConv::run(inputs[0], outputs[0], weightsMat, biasvec, reluslope, kernel_size, strides, pads_begin, pads_end, dilations, activ.get(), ngroups, nstripes); } -#if CV_SSE3 - _MM_SET_FLUSH_ZERO_MODE(ftzMode); - _MM_SET_DENORMALS_ZERO_MODE(dazMode); -#endif } virtual int64 getFLOPS(const std::vector &inputs, diff --git a/modules/dnn/src/onnx/onnx_importer.cpp b/modules/dnn/src/onnx/onnx_importer.cpp index 47ec830313539425b28c9bafebb2498d1e90e22d..f68b1ccf2f3631cfbb2847627f71cd632216e352 100644 --- a/modules/dnn/src/onnx/onnx_importer.cpp +++ b/modules/dnn/src/onnx/onnx_importer.cpp @@ -8,6 +8,8 @@ #include "../precomp.hpp" #include +#include + #include #undef CV_LOG_STRIP_LEVEL #define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1 @@ -40,6 +42,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN class ONNXImporter { + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + opencv_onnx::ModelProto model_proto; struct LayerInfo { int layerId; diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 8cbe1c4b2393cf2d8351a7aaff1c0d1ccd64afaf..43ab1a93acae61993a0a5e8833ddf5c5bc906570 100644 --- a/modules/dnn/src/tensorflow/tf_importer.cpp +++ b/modules/dnn/src/tensorflow/tf_importer.cpp @@ -11,6 +11,8 @@ Implementation of Tensorflow models parser #include "../precomp.hpp" +#include + #include #include #undef CV_LOG_STRIP_LEVEL @@ -509,6 +511,7 @@ void ExcludeLayer(tensorflow::GraphDef& net, const int layer_index, const int in class TFImporter { + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; public: TFImporter(Net& net, const char *model, const char *config = NULL); TFImporter(Net& net, const char *dataModel, size_t lenModel, diff --git a/modules/dnn/src/torch/torch_importer.cpp b/modules/dnn/src/torch/torch_importer.cpp index 5dd9e3e2908ab6b21e44010f4048f69b13d6771a..f158bc12c2063da6030ceb55a01325e90ff12770 100644 --- a/modules/dnn/src/torch/torch_importer.cpp +++ b/modules/dnn/src/torch/torch_importer.cpp @@ -40,6 +40,9 @@ //M*/ #include "../precomp.hpp" + +#include + #include #include #include @@ -106,6 +109,8 @@ static inline bool endsWith(const String &str, const char *substr) struct TorchImporter { + FPDenormalsIgnoreHintScope fp_denormals_ignore_scope; + typedef std::map > TensorsMap; Net net;