Commit f3237fdc authored by Alexander Alekhin's avatar Alexander Alekhin

Merge remote-tracking branch 'upstream/3.4' into merge-3.4

parents cc259e49 a8c257ce
...@@ -64,12 +64,3 @@ else() ...@@ -64,12 +64,3 @@ else()
endif() endif()
endforeach(flag_var) endforeach(flag_var)
endif() endif()
if(CMAKE_VERSION VERSION_GREATER "2.8.6")
include(ProcessorCount)
ProcessorCount(N)
if(NOT N EQUAL 0)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${N} ")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${N} ")
endif()
endif()
...@@ -444,3 +444,38 @@ if(OPENCV_EXTRA_RPATH_LINK_PATH) ...@@ -444,3 +444,38 @@ if(OPENCV_EXTRA_RPATH_LINK_PATH)
message(WARNING "OPENCV_EXTRA_RPATH_LINK_PATH may not work properly because CMAKE_EXECUTABLE_RPATH_LINK_CXX_FLAG is not defined (not supported)") message(WARNING "OPENCV_EXTRA_RPATH_LINK_PATH may not work properly because CMAKE_EXECUTABLE_RPATH_LINK_CXX_FLAG is not defined (not supported)")
endif() endif()
endif() endif()
# Control MSVC /MP flag
# Input variables: OPENCV_MSVC_PARALLEL (ON,1,2,3,...) + OPENCV_SKIP_MSVC_PARALLEL
# Details:
# - https://docs.microsoft.com/en-us/cpp/build/reference/mp-build-with-multiple-processes
# - https://docs.microsoft.com/en-us/cpp/build/reference/cl-environment-variables
# - https://gitlab.kitware.com/cmake/cmake/merge_requests/1718/diffs
if(CMAKE_GENERATOR MATCHES "Visual Studio" AND CMAKE_CXX_COMPILER_ID MATCHES "MSVC|Intel")
ocv_check_environment_variables(OPENCV_SKIP_MSVC_PARALLEL)
if(OPENCV_SKIP_MSVC_PARALLEL)
# nothing
elseif(" ${CMAKE_CXX_FLAGS}" MATCHES "/MP")
# nothing, already defined in compiler flags
elseif(DEFINED ENV{CL} AND " $ENV{CL}" MATCHES "/MP")
# nothing, compiler will use CL environment variable
elseif(DEFINED ENV{_CL_} AND " $ENV{_CL_}" MATCHES "/MP")
# nothing, compiler will use _CL_ environment variable
else()
ocv_check_environment_variables(OPENCV_MSVC_PARALLEL)
set(_mp_value "ON")
if(DEFINED OPENCV_MSVC_PARALLEL)
set(_mp_value "${OPENCV_MSVC_PARALLEL}")
endif()
set(OPENCV_MSVC_PARALLEL "${_mp_value}" CACHE STRING "Control MSVC /MP flag")
if(_mp_value)
if(_mp_value GREATER 0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP${_mp_value}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP${_mp_value}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
endif()
endif()
endif()
endif()
...@@ -92,9 +92,9 @@ endif() ...@@ -92,9 +92,9 @@ endif()
if(INF_ENGINE_TARGET) if(INF_ENGINE_TARGET)
if(NOT INF_ENGINE_RELEASE) if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version have not been set, 2019R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.") message(WARNING "InferenceEngine version has not been set, 2020.1 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
endif() endif()
set(INF_ENGINE_RELEASE "2019030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)") set(INF_ENGINE_RELEASE "2020010000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}" INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
) )
......
This diff is collapsed.
...@@ -119,13 +119,18 @@ public: ...@@ -119,13 +119,18 @@ public:
} }
}; };
ElementWiseLayer(const Func &f=Func()) : run_parallel(false) { func = f; } ElementWiseLayer(const Func &f=Func()) { func = f; }
virtual bool supportBackend(int backendId) CV_OVERRIDE virtual bool supportBackend(int backendId) CV_OVERRIDE
{ {
return func.supportBackend(backendId, this->preferableTarget); return func.supportBackend(backendId, this->preferableTarget);
} }
virtual void finalize(InputArrayOfArrays, OutputArrayOfArrays) CV_OVERRIDE
{
func.finalize();
}
virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node) CV_OVERRIDE virtual Ptr<BackendNode> tryAttach(const Ptr<BackendNode>& node) CV_OVERRIDE
{ {
switch (node->backendId) switch (node->backendId)
...@@ -262,7 +267,6 @@ public: ...@@ -262,7 +267,6 @@ public:
} }
Func func; Func func;
bool run_parallel;
}; };
#ifdef HAVE_OPENCL #ifdef HAVE_OPENCL
...@@ -277,7 +281,16 @@ static String oclGetTMacro(const UMat &m) ...@@ -277,7 +281,16 @@ static String oclGetTMacro(const UMat &m)
} }
#endif #endif
struct ReLUFunctor struct BaseFunctor
{
void finalize() {}
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
};
struct ReLUFunctor : public BaseFunctor
{ {
typedef ReLULayer Layer; typedef ReLULayer Layer;
float slope; float slope;
...@@ -421,14 +434,10 @@ struct ReLUFunctor ...@@ -421,14 +434,10 @@ struct ReLUFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 1; } int64 getFLOPSPerElement() const { return 1; }
}; };
struct ReLU6Functor struct ReLU6Functor : public BaseFunctor
{ {
typedef ReLU6Layer Layer; typedef ReLU6Layer Layer;
float minValue, maxValue; float minValue, maxValue;
...@@ -548,14 +557,10 @@ struct ReLU6Functor ...@@ -548,14 +557,10 @@ struct ReLU6Functor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 2; } int64 getFLOPSPerElement() const { return 2; }
}; };
struct TanHFunctor struct TanHFunctor : public BaseFunctor
{ {
typedef TanHLayer Layer; typedef TanHLayer Layer;
...@@ -644,14 +649,10 @@ struct TanHFunctor ...@@ -644,14 +649,10 @@ struct TanHFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 1; } int64 getFLOPSPerElement() const { return 1; }
}; };
struct SwishFunctor struct SwishFunctor : public BaseFunctor
{ {
typedef SwishLayer Layer; typedef SwishLayer Layer;
...@@ -740,15 +741,10 @@ struct SwishFunctor ...@@ -740,15 +741,10 @@ struct SwishFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 3; } int64 getFLOPSPerElement() const { return 3; }
}; };
struct MishFunctor struct MishFunctor : public BaseFunctor
{ {
typedef MishLayer Layer; typedef MishLayer Layer;
...@@ -842,15 +838,10 @@ struct MishFunctor ...@@ -842,15 +838,10 @@ struct MishFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 3; } int64 getFLOPSPerElement() const { return 3; }
}; };
struct SigmoidFunctor struct SigmoidFunctor : public BaseFunctor
{ {
typedef SigmoidLayer Layer; typedef SigmoidLayer Layer;
...@@ -939,19 +930,13 @@ struct SigmoidFunctor ...@@ -939,19 +930,13 @@ struct SigmoidFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 3; } int64 getFLOPSPerElement() const { return 3; }
}; };
struct ELUFunctor struct ELUFunctor : public BaseFunctor
{ {
typedef ELULayer Layer; typedef ELULayer Layer;
explicit ELUFunctor() {}
bool supportBackend(int backendId, int) bool supportBackend(int backendId, int)
{ {
return backendId == DNN_BACKEND_OPENCV || return backendId == DNN_BACKEND_OPENCV ||
...@@ -1037,14 +1022,10 @@ struct ELUFunctor ...@@ -1037,14 +1022,10 @@ struct ELUFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 2; } int64 getFLOPSPerElement() const { return 2; }
}; };
struct AbsValFunctor struct AbsValFunctor : public BaseFunctor
{ {
typedef AbsLayer Layer; typedef AbsLayer Layer;
...@@ -1139,14 +1120,10 @@ struct AbsValFunctor ...@@ -1139,14 +1120,10 @@ struct AbsValFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 1; } int64 getFLOPSPerElement() const { return 1; }
}; };
struct BNLLFunctor struct BNLLFunctor : public BaseFunctor
{ {
typedef BNLLLayer Layer; typedef BNLLLayer Layer;
...@@ -1236,23 +1213,19 @@ struct BNLLFunctor ...@@ -1236,23 +1213,19 @@ struct BNLLFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 5; } int64 getFLOPSPerElement() const { return 5; }
}; };
struct PowerFunctor struct PowerFunctor : public BaseFunctor
{ {
typedef PowerLayer Layer; typedef PowerLayer Layer;
float power; float power, scale, shift;
float scale; float originPower, originScale, originShift;
float shift;
explicit PowerFunctor(float power_ = 1.f, float scale_ = 1.f, float shift_ = 0.f) explicit PowerFunctor(float power_ = 1.f, float scale_ = 1.f, float shift_ = 0.f)
: power(power_), scale(scale_), shift(shift_) {} : power(power_), scale(scale_), shift(shift_),
originPower(power_), originScale(scale_), originShift(shift_) {}
bool supportBackend(int backendId, int targetId) bool supportBackend(int backendId, int targetId)
{ {
...@@ -1266,6 +1239,13 @@ struct PowerFunctor ...@@ -1266,6 +1239,13 @@ struct PowerFunctor
backendId == DNN_BACKEND_HALIDE; backendId == DNN_BACKEND_HALIDE;
} }
void finalize()
{
power = originPower;
scale = originScale;
shift = originShift;
}
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
{ {
float a = scale, b = shift, p = power; float a = scale, b = shift, p = power;
...@@ -1410,8 +1390,7 @@ struct PowerFunctor ...@@ -1410,8 +1390,7 @@ struct PowerFunctor
int64 getFLOPSPerElement() const { return power == 1 ? 2 : 10; } int64 getFLOPSPerElement() const { return power == 1 ? 2 : 10; }
}; };
struct ChannelsPReLUFunctor : public BaseFunctor
struct ChannelsPReLUFunctor
{ {
typedef ChannelsPReLULayer Layer; typedef ChannelsPReLULayer Layer;
Mat scale; Mat scale;
...@@ -1545,10 +1524,6 @@ struct ChannelsPReLUFunctor ...@@ -1545,10 +1524,6 @@ struct ChannelsPReLUFunctor
} }
#endif // HAVE_VULKAN #endif // HAVE_VULKAN
bool tryFuse(Ptr<dnn::Layer>&) { return false; }
void getScaleShift(Mat&, Mat&) const {}
int64 getFLOPSPerElement() const { return 1; } int64 getFLOPSPerElement() const { return 1; }
}; };
......
...@@ -23,10 +23,11 @@ ...@@ -23,10 +23,11 @@
#define INF_ENGINE_RELEASE_2019R1 2019010000 #define INF_ENGINE_RELEASE_2019R1 2019010000
#define INF_ENGINE_RELEASE_2019R2 2019020000 #define INF_ENGINE_RELEASE_2019R2 2019020000
#define INF_ENGINE_RELEASE_2019R3 2019030000 #define INF_ENGINE_RELEASE_2019R3 2019030000
#define INF_ENGINE_RELEASE_2020_1 2020010000
#ifndef INF_ENGINE_RELEASE #ifndef INF_ENGINE_RELEASE
#warning("IE version have not been provided via command-line. Using 2019R3 by default") #warning("IE version have not been provided via command-line. Using 2019.1 by default")
#define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2019R3 #define INF_ENGINE_RELEASE INF_ENGINE_RELEASE_2020_1
#endif #endif
#define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000)) #define INF_ENGINE_VER_MAJOR_GT(ver) (((INF_ENGINE_RELEASE) / 10000) > ((ver) / 10000))
...@@ -49,7 +50,7 @@ ...@@ -49,7 +50,7 @@
#pragma warning(disable: 4996) // was declared deprecated #pragma warning(disable: 4996) // was declared deprecated
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LT(INF_ENGINE_RELEASE_2020_1)
#pragma GCC visibility push(default) #pragma GCC visibility push(default)
#endif #endif
...@@ -57,7 +58,7 @@ ...@@ -57,7 +58,7 @@
#include <ie_builders.hpp> #include <ie_builders.hpp>
#if defined(__GNUC__) #if defined(__GNUC__) && INF_ENGINE_VER_MAJOR_LT(INF_ENGINE_RELEASE_2020_1)
#pragma GCC visibility pop #pragma GCC visibility pop
#endif #endif
......
...@@ -1297,7 +1297,7 @@ protected: ...@@ -1297,7 +1297,7 @@ protected:
{ {
public: public:
ParallelSearch(vector< vector< Point2f > >& true_points_group_, ParallelSearch(vector< vector< Point2f > >& true_points_group_,
vector< vector< Point2f > >& loc_, int iter_, int* end_, vector< vector< Point2f > >& loc_, int iter_, vector<int>& end_,
vector< vector< Vec3i > >& all_points_, vector< vector< Vec3i > >& all_points_,
QRDetectMulti& cl_) QRDetectMulti& cl_)
: :
...@@ -1313,7 +1313,7 @@ protected: ...@@ -1313,7 +1313,7 @@ protected:
vector< vector< Point2f > >& true_points_group; vector< vector< Point2f > >& true_points_group;
vector< vector< Point2f > >& loc; vector< vector< Point2f > >& loc;
int iter; int iter;
int* end; vector<int>& end;
vector< vector< Vec3i > >& all_points; vector< vector< Vec3i > >& all_points;
QRDetectMulti& cl; QRDetectMulti& cl;
}; };
...@@ -1925,7 +1925,7 @@ bool QRDetectMulti::checkSets(vector<vector<Point2f> >& true_points_group, vecto ...@@ -1925,7 +1925,7 @@ bool QRDetectMulti::checkSets(vector<vector<Point2f> >& true_points_group, vecto
return false; return false;
int* set_size = new int[true_points_group.size()]; vector<int> set_size(true_points_group.size());
for (size_t i = 0; i < true_points_group.size(); i++) for (size_t i = 0; i < true_points_group.size(); i++)
{ {
set_size[i] = int(0.5 * (true_points_group[i].size() - 2 ) * (true_points_group[i].size() - 1)); set_size[i] = int(0.5 * (true_points_group[i].size() - 2 ) * (true_points_group[i].size() - 1));
...@@ -1963,7 +1963,7 @@ bool QRDetectMulti::checkSets(vector<vector<Point2f> >& true_points_group, vecto ...@@ -1963,7 +1963,7 @@ bool QRDetectMulti::checkSets(vector<vector<Point2f> >& true_points_group, vecto
transformation_points.resize(iter + true_points_group.size()); transformation_points.resize(iter + true_points_group.size());
true_points_group_copy = true_points_group; true_points_group_copy = true_points_group;
int* end = new int[true_points_group.size()]; vector<int> end(true_points_group.size());
for (size_t i = 0; i < true_points_group.size(); i++) for (size_t i = 0; i < true_points_group.size(); i++)
end[i] = iter + set_size[i]; end[i] = iter + set_size[i];
ParallelSearch parallelSearch(true_points_group, ParallelSearch parallelSearch(true_points_group,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment