mirror of
https://github.com/opencv/opencv.git
synced 2024-11-26 04:00:30 +08:00
Merge pull request #12837 from dkurt:dnn_fix_ie
This commit is contained in:
commit
113793fee7
@ -1511,10 +1511,10 @@ struct Net::Impl
|
|||||||
CV_Assert(!ieNode.empty());
|
CV_Assert(!ieNode.empty());
|
||||||
ieNode->net = net;
|
ieNode->net = net;
|
||||||
|
|
||||||
|
auto weightableLayer = std::dynamic_pointer_cast<InferenceEngine::WeightableLayer>(ieNode->layer);
|
||||||
if ((preferableTarget == DNN_TARGET_OPENCL_FP16 || preferableTarget == DNN_TARGET_MYRIAD) && !fused)
|
if ((preferableTarget == DNN_TARGET_OPENCL_FP16 || preferableTarget == DNN_TARGET_MYRIAD) && !fused)
|
||||||
{
|
{
|
||||||
ieNode->layer->precision = InferenceEngine::Precision::FP16;
|
ieNode->layer->precision = InferenceEngine::Precision::FP16;
|
||||||
auto weightableLayer = std::dynamic_pointer_cast<InferenceEngine::WeightableLayer>(ieNode->layer);
|
|
||||||
if (weightableLayer)
|
if (weightableLayer)
|
||||||
{
|
{
|
||||||
if (weightableLayer->_weights)
|
if (weightableLayer->_weights)
|
||||||
@ -1532,7 +1532,13 @@ struct Net::Impl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (weightableLayer)
|
||||||
|
{
|
||||||
|
if (weightableLayer->_weights)
|
||||||
|
weightableLayer->blobs["weights"] = weightableLayer->_weights;
|
||||||
|
if (weightableLayer->_biases)
|
||||||
|
weightableLayer->blobs["biases"] = weightableLayer->_biases;
|
||||||
|
}
|
||||||
ieNode->connect(ld.inputBlobsWrappers, ld.outputBlobsWrappers);
|
ieNode->connect(ld.inputBlobsWrappers, ld.outputBlobsWrappers);
|
||||||
net->addBlobs(ld.inputBlobsWrappers);
|
net->addBlobs(ld.inputBlobsWrappers);
|
||||||
net->addBlobs(ld.outputBlobsWrappers);
|
net->addBlobs(ld.outputBlobsWrappers);
|
||||||
|
@ -449,15 +449,28 @@ public:
|
|||||||
lp.precision = InferenceEngine::Precision::FP32;
|
lp.precision = InferenceEngine::Precision::FP32;
|
||||||
std::shared_ptr<InferenceEngine::ConvolutionLayer> ieLayer(new InferenceEngine::ConvolutionLayer(lp));
|
std::shared_ptr<InferenceEngine::ConvolutionLayer> ieLayer(new InferenceEngine::ConvolutionLayer(lp));
|
||||||
|
|
||||||
|
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
|
||||||
|
ieLayer->_kernel.insert(InferenceEngine::X_AXIS, kernel.width);
|
||||||
|
ieLayer->_kernel.insert(InferenceEngine::Y_AXIS, kernel.height);
|
||||||
|
ieLayer->_stride.insert(InferenceEngine::X_AXIS, stride.width);
|
||||||
|
ieLayer->_stride.insert(InferenceEngine::Y_AXIS, stride.height);
|
||||||
|
ieLayer->_padding.insert(InferenceEngine::X_AXIS, pad.width);
|
||||||
|
ieLayer->_padding.insert(InferenceEngine::Y_AXIS, pad.height);
|
||||||
|
ieLayer->_pads_end.insert(InferenceEngine::X_AXIS, pad.width);
|
||||||
|
ieLayer->_pads_end.insert(InferenceEngine::Y_AXIS, pad.height);
|
||||||
|
ieLayer->_dilation.insert(InferenceEngine::X_AXIS, dilation.width);
|
||||||
|
ieLayer->_dilation.insert(InferenceEngine::Y_AXIS, dilation.height);
|
||||||
|
#else
|
||||||
ieLayer->_kernel_x = kernel.width;
|
ieLayer->_kernel_x = kernel.width;
|
||||||
ieLayer->_kernel_y = kernel.height;
|
ieLayer->_kernel_y = kernel.height;
|
||||||
ieLayer->_stride_x = stride.width;
|
ieLayer->_stride_x = stride.width;
|
||||||
ieLayer->_stride_y = stride.height;
|
ieLayer->_stride_y = stride.height;
|
||||||
ieLayer->_out_depth = outCn;
|
|
||||||
ieLayer->_padding_x = pad.width;
|
ieLayer->_padding_x = pad.width;
|
||||||
ieLayer->_padding_y = pad.height;
|
ieLayer->_padding_y = pad.height;
|
||||||
ieLayer->_dilation_x = dilation.width;
|
ieLayer->_dilation_x = dilation.width;
|
||||||
ieLayer->_dilation_y = dilation.height;
|
ieLayer->_dilation_y = dilation.height;
|
||||||
|
#endif
|
||||||
|
ieLayer->_out_depth = outCn;
|
||||||
ieLayer->_group = group;
|
ieLayer->_group = group;
|
||||||
|
|
||||||
ieLayer->_weights = wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW);
|
ieLayer->_weights = wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW);
|
||||||
@ -1659,15 +1672,28 @@ public:
|
|||||||
lp.precision = InferenceEngine::Precision::FP32;
|
lp.precision = InferenceEngine::Precision::FP32;
|
||||||
std::shared_ptr<InferenceEngine::DeconvolutionLayer> ieLayer(new InferenceEngine::DeconvolutionLayer(lp));
|
std::shared_ptr<InferenceEngine::DeconvolutionLayer> ieLayer(new InferenceEngine::DeconvolutionLayer(lp));
|
||||||
|
|
||||||
|
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
|
||||||
|
ieLayer->_kernel.insert(InferenceEngine::X_AXIS, kernel.width);
|
||||||
|
ieLayer->_kernel.insert(InferenceEngine::Y_AXIS, kernel.height);
|
||||||
|
ieLayer->_stride.insert(InferenceEngine::X_AXIS, stride.width);
|
||||||
|
ieLayer->_stride.insert(InferenceEngine::Y_AXIS, stride.height);
|
||||||
|
ieLayer->_padding.insert(InferenceEngine::X_AXIS, pad.width);
|
||||||
|
ieLayer->_padding.insert(InferenceEngine::Y_AXIS, pad.height);
|
||||||
|
ieLayer->_pads_end.insert(InferenceEngine::X_AXIS, pad.width);
|
||||||
|
ieLayer->_pads_end.insert(InferenceEngine::Y_AXIS, pad.height);
|
||||||
|
ieLayer->_dilation.insert(InferenceEngine::X_AXIS, dilation.width);
|
||||||
|
ieLayer->_dilation.insert(InferenceEngine::Y_AXIS, dilation.height);
|
||||||
|
#else
|
||||||
ieLayer->_kernel_x = kernel.width;
|
ieLayer->_kernel_x = kernel.width;
|
||||||
ieLayer->_kernel_y = kernel.height;
|
ieLayer->_kernel_y = kernel.height;
|
||||||
ieLayer->_stride_x = stride.width;
|
ieLayer->_stride_x = stride.width;
|
||||||
ieLayer->_stride_y = stride.height;
|
ieLayer->_stride_y = stride.height;
|
||||||
ieLayer->_out_depth = numOutput;
|
|
||||||
ieLayer->_padding_x = pad.width;
|
ieLayer->_padding_x = pad.width;
|
||||||
ieLayer->_padding_y = pad.height;
|
ieLayer->_padding_y = pad.height;
|
||||||
ieLayer->_dilation_x = dilation.width;
|
ieLayer->_dilation_x = dilation.width;
|
||||||
ieLayer->_dilation_y = dilation.height;
|
ieLayer->_dilation_y = dilation.height;
|
||||||
|
#endif
|
||||||
|
ieLayer->_out_depth = numOutput;
|
||||||
ieLayer->_group = group;
|
ieLayer->_group = group;
|
||||||
|
|
||||||
ieLayer->_weights = wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW);
|
ieLayer->_weights = wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW);
|
||||||
|
@ -268,6 +268,16 @@ public:
|
|||||||
{
|
{
|
||||||
lp.type = "Pooling";
|
lp.type = "Pooling";
|
||||||
InferenceEngine::PoolingLayer* poolLayer = new InferenceEngine::PoolingLayer(lp);
|
InferenceEngine::PoolingLayer* poolLayer = new InferenceEngine::PoolingLayer(lp);
|
||||||
|
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
|
||||||
|
poolLayer->_kernel.insert(InferenceEngine::X_AXIS, kernel.width);
|
||||||
|
poolLayer->_kernel.insert(InferenceEngine::Y_AXIS, kernel.height);
|
||||||
|
poolLayer->_stride.insert(InferenceEngine::X_AXIS, stride.width);
|
||||||
|
poolLayer->_stride.insert(InferenceEngine::Y_AXIS, stride.height);
|
||||||
|
poolLayer->_padding.insert(InferenceEngine::X_AXIS, pad_l);
|
||||||
|
poolLayer->_padding.insert(InferenceEngine::Y_AXIS, pad_t);
|
||||||
|
poolLayer->_pads_end.insert(InferenceEngine::X_AXIS, pad_r);
|
||||||
|
poolLayer->_pads_end.insert(InferenceEngine::Y_AXIS, pad_b);
|
||||||
|
#else
|
||||||
poolLayer->_kernel_x = kernel.width;
|
poolLayer->_kernel_x = kernel.width;
|
||||||
poolLayer->_kernel_y = kernel.height;
|
poolLayer->_kernel_y = kernel.height;
|
||||||
poolLayer->_stride_x = stride.width;
|
poolLayer->_stride_x = stride.width;
|
||||||
@ -276,6 +286,7 @@ public:
|
|||||||
poolLayer->_padding_y = pad_t;
|
poolLayer->_padding_y = pad_t;
|
||||||
poolLayer->params["pad-r"] = format("%d", pad_r);
|
poolLayer->params["pad-r"] = format("%d", pad_r);
|
||||||
poolLayer->params["pad-b"] = format("%d", pad_b);
|
poolLayer->params["pad-b"] = format("%d", pad_b);
|
||||||
|
#endif
|
||||||
poolLayer->_exclude_pad = type == AVE && padMode == "SAME";
|
poolLayer->_exclude_pad = type == AVE && padMode == "SAME";
|
||||||
poolLayer->params["rounding-type"] = ceilMode ? "ceil" : "floor";
|
poolLayer->params["rounding-type"] = ceilMode ? "ceil" : "floor";
|
||||||
poolLayer->_type = type == MAX ? InferenceEngine::PoolingLayer::PoolType::MAX :
|
poolLayer->_type = type == MAX ? InferenceEngine::PoolingLayer::PoolType::MAX :
|
||||||
|
Loading…
Reference in New Issue
Block a user