mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #13841 from dkurt:dnn_ie_future_3
This commit is contained in:
@@ -350,11 +350,10 @@ public:
|
||||
{
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5)
|
||||
InferenceEngine::Builder::ScaleShiftLayer ieLayer(name);
|
||||
|
||||
InferenceEngine::Builder::Layer ieLayer = InferenceEngine::Builder::ScaleShiftLayer(name);
|
||||
const size_t numChannels = weights_.total();
|
||||
ieLayer.setWeights(wrapToInfEngineBlob(weights_, {numChannels}, InferenceEngine::Layout::C));
|
||||
ieLayer.setBiases(wrapToInfEngineBlob(bias_, {numChannels}, InferenceEngine::Layout::C));
|
||||
addConstantData("weights", wrapToInfEngineBlob(weights_, {numChannels}, InferenceEngine::Layout::C), ieLayer);
|
||||
addConstantData("biases", wrapToInfEngineBlob(bias_, {numChannels}, InferenceEngine::Layout::C), ieLayer);
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||
#else
|
||||
InferenceEngine::LayerParams lp;
|
||||
|
||||
@@ -125,7 +125,9 @@ public:
|
||||
ieLayer.getParameters()["axis"] = input->dims.size() - 1;
|
||||
ieLayer.getParameters()["out_sizes"] = input->dims[0];
|
||||
}
|
||||
ieLayer.setInputPorts(std::vector<InferenceEngine::Port>(1));
|
||||
std::vector<size_t> shape(input->dims);
|
||||
std::reverse(shape.begin(), shape.end());
|
||||
ieLayer.setInputPorts({InferenceEngine::Port(shape)});
|
||||
ieLayer.setOutputPorts(std::vector<InferenceEngine::Port>(1));
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||
#else
|
||||
|
||||
@@ -493,11 +493,11 @@ public:
|
||||
ieLayer.setGroup((size_t)group);
|
||||
ieLayer.setOutDepth((size_t)outCn);
|
||||
|
||||
ieLayer.setWeights(ieWeights);
|
||||
if (ieBiases)
|
||||
ieLayer.setBiases(ieBiases);
|
||||
|
||||
InferenceEngine::Builder::Layer l = ieLayer;
|
||||
addConstantData("weights", ieWeights, l);
|
||||
if (ieBiases)
|
||||
addConstantData("biases", ieBiases, l);
|
||||
|
||||
if (!padMode.empty())
|
||||
l.getParameters()["auto_pad"] = padMode == "VALID" ? std::string("valid") : std::string("same_upper");
|
||||
|
||||
@@ -1725,12 +1725,11 @@ public:
|
||||
ieLayer.setGroup((size_t)group);
|
||||
ieLayer.setOutDepth((size_t)numOutput);
|
||||
|
||||
ieLayer.setWeights(wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW));
|
||||
InferenceEngine::Builder::Layer l = ieLayer;
|
||||
addConstantData("weights", wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW), l);
|
||||
if (hasBias())
|
||||
{
|
||||
ieLayer.setBiases(wrapToInfEngineBlob(blobs[1], {(size_t)numOutput}, InferenceEngine::Layout::C));
|
||||
}
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||
addConstantData("biases", wrapToInfEngineBlob(blobs[1], {(size_t)numOutput}, InferenceEngine::Layout::C), l);
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(l));
|
||||
#else
|
||||
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW layout
|
||||
const int group = numOutput / outGroupCn;
|
||||
|
||||
@@ -1134,10 +1134,10 @@ struct ChannelsPReLUFunctor
|
||||
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5)
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
InferenceEngine::Builder::PReLULayer ieLayer("");
|
||||
InferenceEngine::Builder::Layer l = InferenceEngine::Builder::PReLULayer("");
|
||||
const size_t numChannels = scale.total();
|
||||
ieLayer.setWeights(wrapToInfEngineBlob(scale, {numChannels}, InferenceEngine::Layout::C));
|
||||
return ieLayer;
|
||||
addConstantData("weights", wrapToInfEngineBlob(scale, {numChannels}, InferenceEngine::Layout::C), l);
|
||||
return l;
|
||||
}
|
||||
#else
|
||||
InferenceEngine::CNNLayerPtr initInfEngine(InferenceEngine::LayerParams& lp)
|
||||
|
||||
@@ -448,11 +448,12 @@ public:
|
||||
const int outNum = blobs[0].size[0];
|
||||
ieLayer.setOutputNum(outNum);
|
||||
|
||||
ieLayer.setWeights(wrapToInfEngineBlob(blobs[0], {(size_t)blobs[0].size[0], (size_t)blobs[0].size[1], 1, 1}, InferenceEngine::Layout::OIHW));
|
||||
InferenceEngine::Builder::Layer l = ieLayer;
|
||||
addConstantData("weights", wrapToInfEngineBlob(blobs[0], {(size_t)blobs[0].size[0], (size_t)blobs[0].size[1], 1, 1}, InferenceEngine::Layout::OIHW), l);
|
||||
if (blobs.size() > 1)
|
||||
ieLayer.setBiases(wrapToInfEngineBlob(blobs[1], {(size_t)outNum}, InferenceEngine::Layout::C));
|
||||
addConstantData("biases", wrapToInfEngineBlob(blobs[1], {(size_t)outNum}, InferenceEngine::Layout::C), l);
|
||||
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(l));
|
||||
#else
|
||||
InferenceEngine::LayerParams lp;
|
||||
lp.name = name;
|
||||
|
||||
@@ -291,7 +291,7 @@ public:
|
||||
l.getParameters()["channel_shared"] = blobs[0].total() == 1;
|
||||
}
|
||||
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R5)
|
||||
l.getParameters()["weights"] = (InferenceEngine::Blob::CPtr)weights;
|
||||
l.getParameters()["weights"] = weights;
|
||||
#else
|
||||
l.addConstantData("weights", weights);
|
||||
#endif
|
||||
|
||||
@@ -524,12 +524,12 @@ public:
|
||||
if (_stepX == _stepY)
|
||||
{
|
||||
l.getParameters()["step"] = _stepX;
|
||||
l.getParameters()["step_h"] = 0.0;
|
||||
l.getParameters()["step_w"] = 0.0;
|
||||
l.getParameters()["step_h"] = 0.0f;
|
||||
l.getParameters()["step_w"] = 0.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
l.getParameters()["step"] = 0.0;
|
||||
l.getParameters()["step"] = 0.0f;
|
||||
l.getParameters()["step_h"] = _stepY;
|
||||
l.getParameters()["step_w"] = _stepX;
|
||||
}
|
||||
|
||||
@@ -198,13 +198,13 @@ public:
|
||||
{
|
||||
#ifdef HAVE_INF_ENGINE
|
||||
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R5)
|
||||
InferenceEngine::Builder::ScaleShiftLayer ieLayer(name);
|
||||
InferenceEngine::Builder::Layer l = InferenceEngine::Builder::ScaleShiftLayer(name);
|
||||
|
||||
CV_Assert(!blobs.empty());
|
||||
const size_t numChannels = blobs[0].total();
|
||||
if (hasWeights)
|
||||
{
|
||||
ieLayer.setWeights(wrapToInfEngineBlob(blobs[0], {numChannels}, InferenceEngine::Layout::C));
|
||||
addConstantData("weights", wrapToInfEngineBlob(blobs[0], {numChannels}, InferenceEngine::Layout::C), l);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -214,11 +214,11 @@ public:
|
||||
|
||||
std::vector<float> ones(numChannels, 1);
|
||||
weights->set(ones);
|
||||
ieLayer.setWeights(weights);
|
||||
addConstantData("weights", weights, l);
|
||||
}
|
||||
if (hasBias)
|
||||
ieLayer.setBiases(wrapToInfEngineBlob(blobs.back(), {numChannels}, InferenceEngine::Layout::C));
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
|
||||
addConstantData("biases", wrapToInfEngineBlob(blobs.back(), {numChannels}, InferenceEngine::Layout::C), l);
|
||||
return Ptr<BackendNode>(new InfEngineBackendNode(l));
|
||||
#else
|
||||
InferenceEngine::LayerParams lp;
|
||||
lp.name = name;
|
||||
|
||||
Reference in New Issue
Block a user