mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 06:26:29 +08:00
Merge pull request #16076 from l-bat:prior_ngraph
This commit is contained in:
commit
51d54ad4f0
@ -579,7 +579,7 @@ struct SwishFunctor
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
return backendId == DNN_BACKEND_OPENCV ||
|
||||
backendId == DNN_BACKEND_HALIDE;
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
@ -640,7 +640,8 @@ struct SwishFunctor
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
auto sigmoid = std::make_shared<ngraph::op::Sigmoid>(node);
|
||||
return std::make_shared<ngraph::op::v1::Multiply>(node, sigmoid);
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
||||
@ -659,7 +660,7 @@ struct MishFunctor
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
return backendId == DNN_BACKEND_OPENCV ||
|
||||
backendId == DNN_BACKEND_HALIDE;
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
@ -720,7 +721,13 @@ struct MishFunctor
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
float one = 1.0f;
|
||||
auto constant = std::make_shared<ngraph::op::Constant>(ngraph::element::f32, ngraph::Shape{1}, &one);
|
||||
auto exp_node = std::make_shared<ngraph::op::v0::Exp>(node);
|
||||
auto sum = std::make_shared<ngraph::op::v1::Add>(constant, exp_node, ngraph::op::AutoBroadcastType::NUMPY);
|
||||
auto log_node = std::make_shared<ngraph::op::v0::Log>(sum);
|
||||
auto tanh_node = std::make_shared<ngraph::op::Tanh>(log_node);
|
||||
return std::make_shared<ngraph::op::v1::Multiply>(node, tanh_node);
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
||||
|
@ -569,8 +569,10 @@ public:
|
||||
auto upper_bounds = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{1}, std::vector<int64_t>{4});
|
||||
auto strides = std::make_shared<ngraph::op::Constant>(ngraph::element::i64, ngraph::Shape{1}, std::vector<int64_t>{1});
|
||||
|
||||
auto slice_layer = std::make_shared<ngraph::op::DynSlice>(layer_shape, lower_bounds, upper_bounds, strides);
|
||||
auto slice_image = std::make_shared<ngraph::op::DynSlice>(image_shape, lower_bounds, upper_bounds, strides);
|
||||
auto slice_layer = std::make_shared<ngraph::op::v1::StridedSlice>(layer_shape,
|
||||
lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
auto slice_image = std::make_shared<ngraph::op::v1::StridedSlice>(image_shape,
|
||||
lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
|
||||
if (_explicitSizes)
|
||||
{
|
||||
|
@ -341,8 +341,9 @@ public:
|
||||
auto strides = std::make_shared<ngraph::op::Constant>(ngraph::element::i64,
|
||||
ngraph::Shape{dims.size()}, std::vector<int64_t>((int64_t)dims.size(), 1));
|
||||
|
||||
auto slice = std::make_shared<ngraph::op::DynSlice>(ieInpNode, lower_bounds, upper_bounds,
|
||||
strides, ngraph::AxisSet{}, ngraph::AxisSet{});
|
||||
auto slice = std::make_shared<ngraph::op::v1::StridedSlice>(ieInpNode,
|
||||
lower_bounds, upper_bounds, strides, std::vector<int64_t>{}, std::vector<int64_t>{});
|
||||
|
||||
return Ptr<BackendNode>(new InfEngineNgraphNode(slice));
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
Loading…
Reference in New Issue
Block a user