From 7867d798f039b2516bcbcfce3aac5ca4021b1002 Mon Sep 17 00:00:00 2001 From: Maxim Andronov Date: Thu, 29 Apr 2021 09:37:28 +0300 Subject: [PATCH] test fixes (#56) * tests fixes * [CPU] GRN node migration on nGraph * Performance problems fixes. Part 3 * unused node creation fix * small fix * serialize tests fixes * fixesafter review --- .../src/mkldnn_plugin/CMakeLists.txt | 2 +- .../src/mkldnn_plugin/mkldnn_exec_network.cpp | 95 +++++----- .../src/mkldnn_plugin/mkldnn_graph.cpp | 104 ++++++----- .../mkldnn_plugin/mkldnn_graph_optimizer.cpp | 76 +++----- .../mkldnn_plugin/mkldnn_infer_request.cpp | 21 ++- .../src/mkldnn_plugin/mkldnn_node.cpp | 3 +- .../src/mkldnn_plugin/mkldnn_plugin.cpp | 168 ++++++++---------- .../convert_to_cpu_specific_opset.hpp | 5 + .../convert_to_swish_cpu.cpp | 41 +++++ .../convert_to_swish_cpu.hpp | 17 ++ .../ngraph_transformations/op/swish_cpu.cpp | 31 ++++ .../ngraph_transformations/op/swish_cpu.hpp | 27 +++ .../ngraph_transformations/reshape_prelu.cpp | 35 ++++ .../ngraph_transformations/reshape_prelu.hpp | 17 ++ .../src/mkldnn_plugin/nodes/grn.cpp | 37 +++- .../src/mkldnn_plugin/nodes/list_tbl.hpp | 2 +- .../src/mkldnn_plugin/nodes/math.cpp | 3 + .../nodes/mkldnn_bin_conv_node.cpp | 21 +-- .../nodes/mkldnn_bin_conv_node.h | 2 + .../nodes/mkldnn_concat_node.cpp | 2 +- .../mkldnn_plugin/nodes/mkldnn_conv_node.cpp | 4 + .../mkldnn_plugin/nodes/mkldnn_conv_node.h | 2 + .../nodes/mkldnn_convert_node.cpp | 9 + .../mkldnn_plugin/nodes/mkldnn_convert_node.h | 2 + .../nodes/mkldnn_deconv_node.cpp | 2 +- .../nodes/mkldnn_eltwise_node.cpp | 19 +- .../mkldnn_plugin/nodes/mkldnn_input_node.cpp | 14 +- .../mkldnn_plugin/nodes/mkldnn_input_node.h | 4 +- .../mkldnn_plugin/nodes/mkldnn_mvn_node.cpp | 4 +- .../nodes/mkldnn_normalize_node.cpp | 2 +- .../mkldnn_plugin/nodes/mkldnn_pad_node.cpp | 7 + .../src/mkldnn_plugin/nodes/psroi_pooling.cpp | 6 +- .../behavior/add_output.cpp | 22 --- .../behavior/memory_states.cpp | 21 --- .../runtime_precision.cpp | 2 +- .../depth_to_space_transformation.cpp | 4 +- .../mat_mul_transformation.cpp | 2 +- .../mat_mul_with_constant_transformation.cpp | 2 +- .../skip_tests_config.cpp | 56 +----- .../plugin/cpu/single_layer_tests/softmax.cpp | 2 +- .../src/add_conver_to_reorder.cpp | 4 +- .../include/behavior/exec_graph_info.hpp | 2 +- .../mat_mul_transformation.cpp | 2 + ngraph/python/tests/__init__.py | 1 + ngraph/python/tests/test_onnx/test_backend.py | 5 +- ngraph/test/onnx/onnx_import.in.cpp | 3 +- ngraph/test/runtime/ie/unit_test.manifest | 52 ------ 47 files changed, 522 insertions(+), 442 deletions(-) create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.cpp create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.hpp create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.cpp create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.hpp create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp create mode 100644 inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.hpp delete mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp delete mode 100644 inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/memory_states.cpp diff --git a/inference-engine/src/mkldnn_plugin/CMakeLists.txt b/inference-engine/src/mkldnn_plugin/CMakeLists.txt index 0ea1be4bd86507..5edcf885a0fd2e 100644 --- a/inference-engine/src/mkldnn_plugin/CMakeLists.txt +++ b/inference-engine/src/mkldnn_plugin/CMakeLists.txt @@ -72,7 +72,7 @@ set(LAYERS ${CMAKE_CURRENT_SOURCE_DIR}/nodes/gather_elements.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nodes/gather_nd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nodes/gather_tree.cpp -# ${CMAKE_CURRENT_SOURCE_DIR}/nodes/grn.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nodes/grn.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nodes/non_max_suppression.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nodes/log_softmax.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nodes/math.cpp diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp index bc9bdff49a09a3..5003e144128bce 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp @@ -20,6 +20,7 @@ #include #include #include +#include using namespace MKLDNNPlugin; using namespace InferenceEngine; @@ -254,56 +255,50 @@ InferenceEngine::Parameter MKLDNNExecNetwork::GetMetric(const std::string &name) } bool MKLDNNExecNetwork::CanProcessDynBatch(const InferenceEngine::CNNNetwork &network) const { - // TODO [NM]: reimplement w/o using legacy API - return false; -// InputsDataMap inputs = network.getInputsInfo(); -// -// CNNLayerSet inputLayers; -// std::unordered_set allLayers; -// -// if (inputs.empty()) -// return false; -// -// auto & secondLayers = getInputTo(inputs.begin()->second->getInputData()); -// if (secondLayers.empty()) -// return false; -// -// bool check_result = true; -// details::UnorderedDFS(allLayers, secondLayers.begin()->second, [&](CNNLayerPtr layer) { -// auto type = TypeFromName(layer->type); -// // This is WA for Tile layer -// auto tileLayer = dynamic_cast(layer.get()); -// if (tileLayer && tileLayer->axis) -// return; -// -// auto reshapeLayer = dynamic_cast(layer.get()); -// if (reshapeLayer && -// type == Reshape && -// (reshapeLayer->outData[0]->getTensorDesc().getDims()[0] == -// reshapeLayer->insData[0].lock()->getTensorDesc().getDims()[0])) { -// return; -// } -// -// if (type != Input && -// type != Output && -// type != Convolution && -// type != Deconvolution && -// type != Activation && -// type != Depthwise && -// type != Lrn && -// type != Pooling && -// type != FullyConnected && -// type != Gemm && -// type != Softmax && -// type != Split && -// type != Concatenation && -// type != Eltwise && -// type != Copy) { -// check_result = false; -// } -// }, false); -// -// return check_result; + InputsDataMap inputs = network.getInputsInfo(); + + if (inputs.empty()) + return false; + + auto function = network.getFunction(); + if (function == nullptr) { + IE_THROW() << "CPU plug-in doesn't support not ngraph-based model!"; + } + + auto ops = function->get_ordered_ops(); + for (auto op : ops) { + auto type = TypeFromName(op->get_type_name()); + if (type == Tile) { + const auto tile = std::dynamic_pointer_cast(op); + const auto repeatsNode = std::dynamic_pointer_cast(tile->get_input_node_shared_ptr(1)); + if (!repeatsNode) + return false; + if (tile && repeatsNode->cast_vector()[0] == 1) + continue; + } + + if (type == Reshape) { + if (op->get_input_shape(0)[0] == op->get_output_shape(0)[0]) + continue; + } + + if (type != Input && + type != Output && + type != Convolution && + type != Deconvolution && + type != Lrn && + type != Pooling && + type != FullyConnected && + type != MatMul && + type != Softmax && + type != Split && + type != Concatenation && + type != Eltwise) { + return false; + } + } + + return true; } IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp index 26872327b35bcc..a7bd822eb30a50 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph.cpp @@ -188,6 +188,8 @@ void MKLDNNGraph::Replicate(const CNNNetwork &network, const MKLDNNExtensionMana InputsDataMap inputsInfo = network.getInputsInfo(); OutputsDataMap outputsInfo = network.getOutputsInfo(); + this->_name = network.getName(); + std::shared_ptr func = network.getFunction(); if (!func) { IE_THROW() << "Function pointer inside CNNNetwork is nullptr"; @@ -270,10 +272,12 @@ void MKLDNNGraph::Replicate(const CNNNetwork &network, const MKLDNNExtensionMana // Add stub output node for unused outputs for (auto unusedOutput : unusedOutputs) { auto parentNode = op2node[unusedOutput.get_node_shared_ptr()]; - auto newResult = std::make_shared(unusedOutput); - newResult->set_friendly_name(std::string("stub_") + std::to_string(unusedOutput.get_index()) + "_" + parentNode->getName()); - const MKLDNNNodePtr outNode(MKLDNNNode::factory().create(newResult, getEngine(), extMgr, weightsCache)); - MKLDNNEdgePtr edge(new MKLDNNEdge(parentNode, outNode, unusedOutput.get_index(), 0)); + const auto port = unusedOutput.get_index(); + const auto nodeName = std::string("stub_") + std::to_string(unusedOutput.get_index()) + "_" + parentNode->getName(); + const MKLDNNNodePtr outNode = std::make_shared(parentNode->outDims[port].ToSizeVector(), + parentNode->getOriginalOutputPrecisionAtPort(port), + nodeName, "Result", getEngine(), weightsCache); + MKLDNNEdgePtr edge(new MKLDNNEdge(parentNode, outNode, port, 0)); outNode->addEdge(edge); graphEdges.push_back(edge); graphNodes.push_back(outNode); @@ -300,25 +304,19 @@ void MKLDNNGraph::Replicate(const CNNNetwork &network, const MKLDNNExtensionMana } } -// -// // Replicate input nodes -// for (const auto& input : inputs) { -// auto inputLayer = getCreatorLayer(input.second->getInputData()).lock(); -// inputNodesMap[input.first] = layer2node[inputLayer]; -// -// // Loading mean images -// MKLDNNDims outDims; -// if (!inputNodesMap[input.first]->getChildEdgeAt(0)->getDims().ndims()) -// outDims = MKLDNNDims(InferenceEngine::SizeVector(1, 1)); -// else -// outDims = MKLDNNDims(inputNodesMap[input.first]->getChildEdgeAt(0)->getDims()); -// if (inputs.find(input.first) != inputs.end()) { -// InputInfo::Ptr ii = inputs[input.first]; -// if (ii && ii->getPreProcess().getNumberOfChannels()) { -// _meanImages[input.first].Load(outDims, ii); -// } -// } -// } + // Loading mean images + for (const auto& input : inputsInfo) { + MKLDNNDims outDims; + if (!inputNodesMap[input.first]->getChildEdgeAt(0)->getDims().ndims()) { + outDims = MKLDNNDims(InferenceEngine::SizeVector(1, 1)); + } else { + outDims = inputNodesMap[input.first]->getChildEdgeAt(0)->getDims(); + } + InputInfo::Ptr ii = inputsInfo[input.first]; + if (ii && ii->getPreProcess().getNumberOfChannels()) { + _meanImages[input.first].Load(outDims, ii); + } + } } void MKLDNNGraph::InitGraph() { @@ -477,23 +475,25 @@ void MKLDNNGraph::InitEdges() { // Check if there is a reorder that supports the type conversion if (edge->getInputDesc().getPrecision() != edge->getOutputDesc().getPrecision() && - !isReorderAvailable(edge->getInputDesc(), edge->getOutputDesc(), this->getEngine())) { - IE_THROW() << "[NM] Not implemented"; -// //If we are here, then we need to insert Convert, because there are no reorders that support such type conversion -// std::string convertName = edge->getParent()->getName() + "_" + -// edge->getInputDesc().getPrecision().name() + "_" + edge->getOutputDesc().getPrecision().name(); -// -// CNNLayerPtr convert(new CNNLayer(LayerParams{convertName, "Convert", edge->getInputDesc().getPrecision()})); -// auto convertNode = std::make_shared(convert, this->getEngine(), this->weightsCache); -// convertNode->setDescs(edge->getInputDesc(), edge->getOutputDesc()); -// InsertNode(edge, convertNode, true); -// -// //Check if reorder is still needed -// if (convertNode->getChildEdgeAt(0)->needReorder()) { -// edge = convertNode->getChildEdgeAt(0); -// } else { -// insertReorder = false; -// } + !isReorderAvailable(edge->getInputDesc(), edge->getOutputDesc(), this->getEngine())) { + //If we are here, then we need to insert Convert, because there are no reorders that support such type conversion + const auto inDesc = edge->getInputDesc(); + const auto outDesc = edge->getOutputDesc(); + + std::string convertName = edge->getParent()->getName() + "_" + + inDesc.getPrecision().name() + "_" + outDesc.getPrecision().name(); + + auto convertNode = std::make_shared(inDesc.getDims(), inDesc.getPrecision(), outDesc.getPrecision(), convertName, + this->getEngine(), this->weightsCache); + convertNode->setDescs(inDesc, outDesc); + InsertNode(edge, convertNode, true); + + //Check if reorder is still needed + if (convertNode->getChildEdgeAt(0)->needReorder()) { + edge = convertNode->getChildEdgeAt(0); + } else { + insertReorder = false; + } } if (insertReorder) { @@ -787,7 +787,29 @@ void MKLDNNGraph::PullOutputData(BlobMap &out) { MB_to_process = std::min(config.batchLimit, MB_to_process); size_t size_to_copy = intr_blob.GetElementsCount() * MB_to_process / MB; - cpu_convert(intr_blob_ptr, ext_blob_ptr, srcPrec, dstPrec, size_to_copy); + const auto actualDesc = node->getParentEdgeAt(0)->getDesc(); + const auto expectedDesc = ext_blob->getTensorDesc(); + + // TODO [NM]: need to create universal reorder which will be detect cases when we really need to use it + // WA: for cases when output shape after transformation will be 1x1x1x1 but model output is scalar + bool isScalarOutput = false; + if (actualDesc.getLayout() == SCALAR) { + isScalarOutput = expectedDesc.getLayout() == SCALAR || + std::accumulate(expectedDesc.getDims().begin(), expectedDesc.getDims().end(), (size_t)1, std::multiplies()) == 1; + } else if (expectedDesc.getLayout() == SCALAR) { + isScalarOutput = actualDesc.getLayout() == SCALAR || + std::accumulate(actualDesc.getDims().begin(), actualDesc.getDims().end(), (size_t)1, std::multiplies()) == 1; + } + + if (actualDesc.getBlockingDesc() != expectedDesc.getBlockingDesc() && !isScalarOutput) { + auto outBlobDesc = MKLDNNMemoryDesc{expectedDesc}; + auto outBloMem = MKLDNNMemory(eng); + outBloMem.Create(outBlobDesc, ext_blob_ptr, false); + + outBloMem.SetData(intr_blob, 0, false); + } else { + cpu_convert(intr_blob_ptr, ext_blob_ptr, srcPrec, dstPrec, size_to_copy); + } } } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp index 82d55a2c092a62..f4a403e42abc1f 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp @@ -98,9 +98,6 @@ void MKLDNNGraphOptimizer::ApplyCommonGraphOptimizations(MKLDNNGraph &graph) { FuseConvolutionAndDWConvolution(graph); graph.RemoveDroppedNodes(); - FuseBinaryConvolutionAndFakeQuantize(graph); - graph.RemoveDroppedNodes(); - FuseConvolutionSumAndConvolutionSumActivation(graph); graph.RemoveDroppedNodes(); @@ -800,7 +797,7 @@ void MKLDNNGraphOptimizer::FuseFullyConnectedAndSimpleOperation(MKLDNNGraph &gra } auto childNode = parentNode->getChildEdgeAt(0)->getChild(); - if (!parentNode->canFuseSimpleOperation(childNode)) { + if (!parentNode->canFuse(childNode)) { parent++; continue; } @@ -1063,7 +1060,7 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndSimpleOperation(MKLDNNGraph &graph) auto& graphNodes = graph.GetNodes(); auto isSutableParentNode = [](MKLDNNNodePtr node) { - return node->getType() == Convolution && node->getChildEdges().size() == 1; + return (node->getType() == Convolution || node->getType() == BinaryConvolution) && node->getChildEdges().size() == 1; }; auto parent = graphNodes.begin(); @@ -1073,9 +1070,10 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndSimpleOperation(MKLDNNGraph &graph) parent++; continue; } + const auto parentNodeType = parentNode->getType(); auto childNode = parentNode->getChildEdgeAt(0)->getChild(); - if (!parentNode->canFuseSimpleOperation(childNode)) { + if (!parentNode->canFuse(childNode)) { parent++; continue; } @@ -1086,7 +1084,7 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndSimpleOperation(MKLDNNGraph &graph) auto parentEdges = childNode->parentEdges; for (auto &parentEdge : parentEdges) { auto p_edge = parentEdge.lock(); - if (p_edge->getParent()->getType() == Convolution) + if (p_edge->getParent()->getType() == parentNodeType) continue; removeEdge(graph, p_edge); @@ -1097,47 +1095,6 @@ void MKLDNNGraphOptimizer::FuseConvolutionAndSimpleOperation(MKLDNNGraph &graph) } } -void MKLDNNGraphOptimizer::FuseBinaryConvolutionAndFakeQuantize(MKLDNNGraph &graph) { - auto& graphNodes = graph.GetNodes(); - - auto isSutableParentNode = [](MKLDNNNodePtr node) { - return node->getType() == BinaryConvolution && node->getChildEdges().size() == 1; - }; - - auto isSutableChildNode = [](MKLDNNNodePtr parentNode, MKLDNNNodePtr childNode) { - if ((parentNode->isConstant() && !childNode->isConstant()) || childNode->getType() != FakeQuantize) - return false; - - auto* binConv = dynamic_cast(parentNode.get()); - if (!binConv) { - return false; - } - - return binConv->canFuse(childNode); - }; - - for (int i = 0; i < graphNodes.size(); i++) { - auto parent = graphNodes[i]; - if (!isSutableParentNode(parent)) continue; - - auto child = parent->getChildEdgeAt(0)->getChild(); - if (!isSutableChildNode(parent, child)) continue; - - child->fuseInto(parent); - - auto parents = child->parentEdges; - for (size_t i = 0; i < parents.size(); i++) { - auto p_edge = parents[i].lock(); - if (p_edge->getParent()->getType() == BinaryConvolution) - continue; - - removeEdge(graph, p_edge); - } - - graph.DropNode(child); - } -} - void MKLDNNGraphOptimizer::FusePoolingAndFakeQuantize(MKLDNNGraph &graph) { auto& graphNodes = graph.GetNodes(); @@ -1269,14 +1226,33 @@ void MKLDNNGraphOptimizer::FuseConvolutionSumAndConvolutionSumActivation(MKLDNNG bool isSutableParent1 = parent1->getType() == Convolution || parent1->getType() == BinaryConvolution; bool isSutableParent2 = parent2->getType() == Convolution || parent2->getType() == BinaryConvolution; + auto canFuseSum = [](MKLDNNBinaryConvolutionNode *binConv, MKLDNNNodePtr fuseCandidate) { + if (binConv->getImplType() == impl_desc_type::ref) + return false; + + if (binConv->isFusedWith(FakeQuantize)) + return false; + + if (fuseCandidate->getAlgorithm() == EltwiseAdd) { + for (auto& fusedNode : binConv->fusedWith) { + const auto eltwise = std::dynamic_pointer_cast(fusedNode); + if (eltwise && eltwise->isSpecialConvolutionAddFusing()) { + return false; + } + } + return true; + } + return false; + }; + auto* binConvNode1 = dynamic_cast(parent1.get()); if (binConvNode1) { - isSutableParent1 = isSutableParent1 && binConvNode1->canFuse(graphNode); + isSutableParent1 = isSutableParent1 && canFuseSum(binConvNode1, graphNode); } auto* binConvNode2 = dynamic_cast(parent2.get()); if (binConvNode2) { - isSutableParent2 = isSutableParent2 && binConvNode2->canFuse(graphNode); + isSutableParent2 = isSutableParent2 && canFuseSum(binConvNode2, graphNode); } auto* convNode1 = dynamic_cast(parent1.get()); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp index 9075839d6ac8ae..e56b892849bf25 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp @@ -228,7 +228,6 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std:: } InferenceEngine::TensorDesc desc = blobs[name]->getTensorDesc(); - InferenceEngine::Precision originPrecision = blobs[name]->getTensorDesc().getPrecision(); if (_networkInputs.find(name) != _networkInputs.end()) { InferenceEngine::Layout l = _networkInputs[name]->getLayout(); InferenceEngine::Precision p = _networkInputs[name]->getPrecision(); @@ -239,7 +238,7 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std:: _inputs[name] = make_blob_with_precision(desc); _inputs[name]->allocate(); - if (desc.getPrecision() == originPrecision && + if (blobs[name]->getTensorDesc() == desc && graph->_meanImages.find(name) == graph->_meanImages.end() && !graph->getProperty().batchLimit) { externalPtr[name] = _inputs[name]->buffer(); } @@ -257,7 +256,7 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std:: } InferenceEngine::TensorDesc desc = _networkOutputs[name]->getTensorDesc();//blobs[name]->getTensorDesc(); - InferenceEngine::Precision originPrecision = blobs[name]->getTensorDesc().getPrecision(); + desc.setPrecision(normalizeToSupportedPrecision(desc.getPrecision())); // WA: need to avoid exception thrown when we compare blocking desc in SetBlob // in situation if we push output blobs as inputs for next network (in Hetero plugin) @@ -268,7 +267,7 @@ InferenceEngine::Blob::Ptr MKLDNNPlugin::MKLDNNInferRequest::GetBlob(const std:: _outputs[name] = make_blob_with_precision(desc); _outputs[name]->allocate(); - if (desc.getPrecision() == originPrecision && !graph->getProperty().batchLimit) { + if (blobs[name]->getTensorDesc() == desc && !graph->getProperty().batchLimit) { externalPtr[name] = _outputs[name]->buffer(); } data = _outputs[name]; @@ -334,7 +333,12 @@ void MKLDNNPlugin::MKLDNNInferRequest::SetBlob(const std::string& name, const In IE_THROW(ParameterMismatch) << "Failed to set input blob. Blocking descriptor mismatch."; } - if (data->getTensorDesc().getPrecision() == InferenceEngine::Precision::FP32 && + InferenceEngine::BlobMap blobs; + graph->getInputBlobs(blobs); + if (blobs.find(name) == blobs.end()) + IE_THROW() << "MKLDNN graph doesn't contain input node with name: " << name; + + if (data->getTensorDesc() == blobs.at(name)->getTensorDesc() && graph->_meanImages.find(name) == graph->_meanImages.end() && !graph->getProperty().batchLimit) { externalPtr[name] = data->buffer(); } else if (externalPtr.find(name) != externalPtr.end()) { @@ -366,7 +370,12 @@ void MKLDNNPlugin::MKLDNNInferRequest::SetBlob(const std::string& name, const In IE_THROW(ParameterMismatch) << "Failed to set output blob. Blocking descriptor mismatch."; } - if (data->getTensorDesc().getPrecision() == InferenceEngine::Precision::FP32 && + InferenceEngine::BlobMap blobs; + graph->getOutputBlobs(blobs); + if (blobs.find(name) == blobs.end()) + IE_THROW() << "MKLDNN graph doesn't contain output node with name: " << name; + + if (data->getTensorDesc() == blobs.at(name)->getTensorDesc() && !graph->getProperty().batchLimit) { externalPtr[name] = data->buffer(); } else if (externalPtr.find(name) != externalPtr.end()) { diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp index 5644fe4ba23222..b725d24e276f47 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_node.cpp @@ -101,7 +101,7 @@ static const InferenceEngine::details::caseless_unordered_map { "Sqrt", Eltwise }, { "Clamp", Eltwise }, { "Exp", Eltwise }, - { "Swish", Eltwise }, + { "SwishCPU", Eltwise }, { "HSwish", Eltwise }, { "Mish", Eltwise }, { "HSigmoid", Eltwise }, @@ -1385,6 +1385,5 @@ bool MKLDNNNode::canFuseSimpleOperation(const MKLDNNNodePtr& node) const { EltwiseRoundHalfAwayFromZero, EltwiseLinear, EltwiseAbs, EltwiseSquare, EltwiseSqrt) || node->canBePerformedAsScaleShift(this); } - return false; } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 97903e85031c54..5e1d603962db63 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -76,6 +76,8 @@ #include #include +#include + #include "nodes/mkldnn_mvn_node.h" #include "nodes/mkldnn_fake_quantize_node.h" #include "ngraph_transformations/convert_to_cpu_specific_opset.hpp" @@ -506,95 +508,83 @@ void Engine::AddExtension(InferenceEngine::IExtensionPtr extension) { QueryNetworkResult Engine::QueryNetwork(const CNNNetwork& network, const std::map& config) const { QueryNetworkResult res; - IE_THROW() << "Not implemented"; -// TODO [NM]: reimplement QueryNetwork on ngraph -// -// MKLDNNWeightsSharing::Ptr fake_w_cache; -// auto function = network.getFunction(); -// if (function != nullptr) { -// std::unordered_set originalOps; -// for (auto&& node : function->get_ops()) { -// originalOps.emplace(node->get_friendly_name()); -// } -// -// // TODO: Clarify the behavior of SetConfig method. Skip eng_config or not? -// Config conf = engConfig; -// conf.readProperties(config); -// -// if (conf.enableDynamicBatch) { -// conf.batchLimit = static_cast(network.getBatchSize()); -// } -// -// auto clonedNetwork = InferenceEngine::cloneNetwork(network); -// Transformation(clonedNetwork, conf); -// std::unordered_set supported; -// std::unordered_set unsupported; -// for (details::CNNNetworkIterator itLayer{clonedNetwork}; itLayer != details::CNNNetworkIterator(); itLayer++) { -// auto layerIsSupported = [&] { -// std::unique_ptr ptr; -// try { -// ptr.reset(MKLDNNNode::factory().create(*itLayer, {mkldnn::engine::kind::cpu, 0}, extensionManager, fake_w_cache)); -// } catch (InferenceEngine::details::InferenceEngineException&) { -// return false; -// } -// return true; -// } (); -// for (auto&& fusedLayerName : ngraph::getFusedNamesVector((*itLayer)->getNode())) { -// if (InferenceEngine::details::contains(originalOps, fusedLayerName)) { -// if (layerIsSupported) { -// supported.emplace(fusedLayerName); -// } else { -// unsupported.emplace(fusedLayerName); -// } -// } -// } -// } -// for (auto&& unsupportedNode : unsupported) { -// supported.erase(unsupportedNode); -// } -// for (auto&& node : function->get_ops()) { -// if (InferenceEngine::details::contains(supported, node->get_friendly_name())) { -// for (auto&& inputNodeOutput : node->input_values()) { -// if (ngraph::op::is_constant(inputNodeOutput.get_node()) || ngraph::op::is_parameter(inputNodeOutput.get_node())) { -// supported.emplace(inputNodeOutput.get_node()->get_friendly_name()); -// } -// } -// for (auto&& outputs : node->outputs()) { -// for (auto&& outputNodeInput : outputs.get_target_inputs()) { -// if (ngraph::op::is_output(outputNodeInput.get_node())) { -// supported.emplace(outputNodeInput.get_node()->get_friendly_name()); -// } -// } -// } -// } -// -// if (ngraph::op::is_constant(node) || ngraph::op::is_parameter(node)) { -// if (!InferenceEngine::details::contains(supported, node->output(0).get_target_inputs().begin()->get_node()->get_friendly_name())) { -// supported.erase(node->get_friendly_name()); -// } -// } else if (ngraph::op::is_output(node)) { -// if (!InferenceEngine::details::contains(supported, node->input_values().begin()->get_node()->get_friendly_name())) { -// supported.erase(node->get_friendly_name()); -// } -// } -// } -// -// for (auto&& layerName : supported) { -// res.supportedLayersMap.emplace(layerName, GetName()); -// } -// } else { -// details::CNNNetworkIterator i(network); -// while (i != details::CNNNetworkIterator()) { -// try { -// mkldnn::engine eng(mkldnn::engine(mkldnn::engine::kind::cpu, 0)); -// // if we can create and have not thrown exception, then layer is supported -// std::unique_ptr (MKLDNNNode::factory().create(*i, eng, extensionManager, fake_w_cache)); -// res.supportedLayersMap.insert({ (*i)->name, GetName() }); -// } catch (InferenceEngine::details::InferenceEngineException&) { -// } -// i++; -// } -// } + MKLDNNWeightsSharing::Ptr fake_w_cache; + auto function = network.getFunction(); + if (function != nullptr) { + std::unordered_set originalOps; + for (auto&& node : function->get_ops()) { + originalOps.emplace(node->get_friendly_name()); + } + + // TODO: Clarify the behavior of SetConfig method. Skip eng_config or not? + Config conf = engConfig; + conf.readProperties(config); + + if (conf.enableDynamicBatch) { + conf.batchLimit = static_cast(network.getBatchSize()); + } + + auto clonedNetwork = InferenceEngine::details::cloneNetwork(network); + auto ops = clonedNetwork.getFunction()->get_ordered_ops(); + Transformation(clonedNetwork, conf); + std::unordered_set supported; + std::unordered_set unsupported; + for (auto op : ops) { + auto layerIsSupported = [&] { + std::unique_ptr ptr; + try { + ptr.reset(MKLDNNNode::factory().create(op, {mkldnn::engine::kind::cpu, 0}, extensionManager, fake_w_cache)); + } catch (InferenceEngine::Exception&) { + return false; + } + return true; + } (); + for (auto&& fusedLayerName : ngraph::getFusedNamesVector(op)) { + if (InferenceEngine::details::contains(originalOps, fusedLayerName)) { + if (layerIsSupported) { + supported.emplace(fusedLayerName); + } else { + unsupported.emplace(fusedLayerName); + } + } + } + } + for (auto&& unsupportedNode : unsupported) { + supported.erase(unsupportedNode); + } + for (auto&& node : function->get_ops()) { + if (InferenceEngine::details::contains(supported, node->get_friendly_name())) { + for (auto&& inputNodeOutput : node->input_values()) { + if (ngraph::op::is_constant(inputNodeOutput.get_node()) || ngraph::op::is_parameter(inputNodeOutput.get_node())) { + supported.emplace(inputNodeOutput.get_node()->get_friendly_name()); + } + } + for (auto&& outputs : node->outputs()) { + for (auto&& outputNodeInput : outputs.get_target_inputs()) { + if (ngraph::op::is_output(outputNodeInput.get_node())) { + supported.emplace(outputNodeInput.get_node()->get_friendly_name()); + } + } + } + } + + if (ngraph::op::is_constant(node) || ngraph::op::is_parameter(node)) { + if (!InferenceEngine::details::contains(supported, node->output(0).get_target_inputs().begin()->get_node()->get_friendly_name())) { + supported.erase(node->get_friendly_name()); + } + } else if (ngraph::op::is_output(node)) { + if (!InferenceEngine::details::contains(supported, node->input_values().begin()->get_node()->get_friendly_name())) { + supported.erase(node->get_friendly_name()); + } + } + } + + for (auto&& layerName : supported) { + res.supportedLayersMap.emplace(layerName, GetName()); + } + } else { + IE_THROW() << "CPU plug-in doesn't support not ngraph-based model!"; + } return res; } diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_cpu_specific_opset.hpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_cpu_specific_opset.hpp index e3feb60e70d18c..f9bef52913bed3 100644 --- a/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_cpu_specific_opset.hpp +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_cpu_specific_opset.hpp @@ -12,11 +12,14 @@ #include "reshape_1d_ops.hpp" #include "convert_to_power_static.hpp" #include "convert_to_leaky_relu.hpp" +#include "convert_to_swish_cpu.hpp" +#include "reshape_prelu.hpp" namespace MKLDNNPlugin { inline void ConvertToCPUSpecificOpset(std::shared_ptr &nGraphFunc) { ngraph::pass::Manager manager; + manager.register_pass(); manager.register_pass(); manager.register_pass(); manager.register_pass(); @@ -29,6 +32,8 @@ inline void ConvertToCPUSpecificOpset(std::shared_ptr &nGraphF manager.register_pass(); manager.register_pass(); manager.register_pass(); + manager.register_pass(); + manager.register_pass(); if (!ngraph::op::util::has_op_with_type(nGraphFunc)) { manager.register_pass(); } diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.cpp new file mode 100644 index 00000000000000..78f1ff516e5339 --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "convert_to_swish_cpu.hpp" + +#include +#include +#include +#include "op/swish_cpu.hpp" + +NGRAPH_RTTI_DEFINITION(MKLDNNPlugin::ConvertToSwishCPU, "ConvertToSwishCPU", 0); + +MKLDNNPlugin::ConvertToSwishCPU::ConvertToSwishCPU() { + auto swish = ngraph::pattern::wrap_type(); + + ngraph::matcher_pass_callback callback = [](ngraph::pattern::Matcher& m) { + auto swish = std::dynamic_pointer_cast (m.get_match_root()); + if (!swish) { + return false; + } + float beta_value = 1.0; + if (swish->input_values().size() == 2) { + auto beta = std::dynamic_pointer_cast(swish->get_input_node_shared_ptr(1)); + + if (!beta || ngraph::shape_size(swish->get_input_shape(1)) != 1) { + return false; + } + beta_value = beta->cast_vector()[0]; + } + + auto swish_cpu = std::make_shared(swish->input(0).get_source_output(), beta_value); + swish_cpu->set_friendly_name(swish->get_friendly_name()); + ngraph::copy_runtime_info(swish, swish_cpu); + ngraph::replace_node(swish, swish_cpu); + return true; + }; + + auto m = std::make_shared(swish, "ConvertToSwishCPU"); + this->register_matcher(m, callback); +} diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.hpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.hpp new file mode 100644 index 00000000000000..98da1e18c6ab8b --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/convert_to_swish_cpu.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace MKLDNNPlugin { + +class ConvertToSwishCPU: public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ConvertToSwishCPU(); +}; + +} // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.cpp new file mode 100644 index 00000000000000..b940eb2bca61e6 --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "swish_cpu.hpp" + +constexpr ngraph::NodeTypeInfo MKLDNNPlugin::SwishNode::type_info; + +MKLDNNPlugin::SwishNode::SwishNode(const ngraph::Output & input, const float alpha) + : Op({input}), m_alpha(alpha) { + constructor_validate_and_infer_types(); +} + +std::shared_ptr MKLDNNPlugin::SwishNode::clone_with_new_inputs(const ngraph::OutputVector& new_args) const { + check_new_args_count(this, new_args); + return std::make_shared(new_args.at(0), m_alpha); +} + +bool MKLDNNPlugin::SwishNode::visit_attributes(ngraph::AttributeVisitor& visitor) { + visitor.on_attribute("alpha", m_alpha); + return true; +} + +void MKLDNNPlugin::SwishNode::validate_and_infer_types() { + set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); +} + +float MKLDNNPlugin::SwishNode::get_alpha() const { + return m_alpha; +} + diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.hpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.hpp new file mode 100644 index 00000000000000..3ff1c30a1ad631 --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/op/swish_cpu.hpp @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace MKLDNNPlugin { + +class SwishNode : public ngraph::op::Op { +public: + static constexpr ngraph::NodeTypeInfo type_info{"SwishCPU", 0}; + const ngraph::NodeTypeInfo &get_type_info() const override { return type_info; } + + explicit SwishNode(const ngraph::Output &input, float alpha = 1.0); + + void validate_and_infer_types() override; + bool visit_attributes(ngraph::AttributeVisitor& visitor) override; + std::shared_ptr clone_with_new_inputs(const ngraph::OutputVector &new_args) const override; + + float get_alpha() const; +protected: + float m_alpha; +}; + +} // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp new file mode 100644 index 00000000000000..0cc1a33cbc3283 --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.cpp @@ -0,0 +1,35 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "reshape_prelu.hpp" + +#include +#include +#include +#include "transformations/utils/utils.hpp" + +NGRAPH_RTTI_DEFINITION(MKLDNNPlugin::ReshapePRelu, "ReshapePRelu", 0); + +MKLDNNPlugin::ReshapePRelu::ReshapePRelu() { + auto prelu = ngraph::pattern::wrap_type({ngraph::pattern::any_input(ngraph::pattern::has_static_shape()), + ngraph::pattern::any_input(ngraph::pattern::has_static_shape())}); + + ngraph::matcher_pass_callback callback = [this](ngraph::pattern::Matcher& m) { + auto prelu = std::dynamic_pointer_cast(m.get_match_root()); + if (!prelu || ngraph::shape_size(prelu->get_input_shape(1)) == 1 || prelu->get_input_shape(1).size() != 1) { + return false; + } + ngraph::Shape new_shape(prelu->input_value(0).get_shape().size(), 1); + new_shape[new_shape.size() > 1 ? 1 : 0] = prelu->input_value(1).get_shape()[0]; + auto slope = ngraph::op::util::reshapeTo(prelu->input_value(1), new_shape); + auto new_prelu = std::make_shared(prelu->input(0).get_source_output(), slope); + new_prelu->set_friendly_name(prelu->get_friendly_name()); + ngraph::copy_runtime_info(prelu, new_prelu); + ngraph::replace_node(prelu, new_prelu); + return true; + }; + + auto m = std::make_shared(prelu, "ReshapePRelu"); + this->register_matcher(m, callback); +} diff --git a/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.hpp b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.hpp new file mode 100644 index 00000000000000..c448624e6edd99 --- /dev/null +++ b/inference-engine/src/mkldnn_plugin/ngraph_transformations/reshape_prelu.hpp @@ -0,0 +1,17 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include + +namespace MKLDNNPlugin { + +class ReshapePRelu: public ngraph::pass::MatcherPass { +public: + NGRAPH_RTTI_DECLARATION; + ReshapePRelu(); +}; + +} // namespace MKLDNNPlugin \ No newline at end of file diff --git a/inference-engine/src/mkldnn_plugin/nodes/grn.cpp b/inference-engine/src/mkldnn_plugin/nodes/grn.cpp index d773ecddc81287..6ee077fd52ff1e 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/grn.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/grn.cpp @@ -8,21 +8,48 @@ #include #include #include "ie_parallel.hpp" +#include + +using namespace MKLDNNPlugin; namespace InferenceEngine { namespace Extensions { namespace Cpu { class GRNImpl: public ExtLayerBase { + bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept { + try { + const auto grn = std::dynamic_pointer_cast(op); + if (!grn) { + errorMessage = "Only opset1 GRN operation is supported"; + return false; + } + } catch (...) { + return false; + } + return true; + } + + std::string errorPrefix; + public: - explicit GRNImpl(const CNNLayer* layer) { + explicit GRNImpl(const std::shared_ptr& op) { try { - if (layer->insData.size() != 1 || layer->outData.empty()) - IE_THROW() << "Incorrect number of input/output edges!"; + std::string errorMessage; + if (!isSupportedOperation(op, errorMessage)) { + IE_THROW(NotImplemented) << errorMessage; + } + + errorPrefix = "GRN layer with name '" + op->get_friendly_name() + "'"; + const auto grn = std::dynamic_pointer_cast(op); + + if (op->get_input_size() != 1 || op->get_output_size() != 1) + IE_THROW() << errorPrefix << " has incorrect number of input/output edges!"; - bias = layer->GetParamAsFloat("bias"); + bias = grn->get_bias(); - addConfig(layer, {{ConfLayout::PLN, false, 0, Precision::FP32}}, {{ConfLayout::PLN, false, 0, Precision::FP32}}); + addConfig(op, {{TensorDescCreatorTypes::ncsp, Precision::FP32, false, 0}}, + {{TensorDescCreatorTypes::ncsp, Precision::FP32, false, 0}}); } catch (InferenceEngine::Exception &ex) { errorMsg = ex.what(); } diff --git a/inference-engine/src/mkldnn_plugin/nodes/list_tbl.hpp b/inference-engine/src/mkldnn_plugin/nodes/list_tbl.hpp index 815c8d15db67d9..8257556f5b7e0e 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/list_tbl.hpp +++ b/inference-engine/src/mkldnn_plugin/nodes/list_tbl.hpp @@ -64,7 +64,7 @@ MKLDNN_EXTENSION_NODE(ShuffleChannelsImpl, ShuffleChannels); MKLDNN_EXTENSION_NODE(BatchToSpaceImpl, BatchToSpace); MKLDNN_EXTENSION_NODE(ExperimentalDetectronPriorGridGeneratorImpl, ExperimentalDetectronPriorGridGenerator); //MKLDNN_EXTENSION_NODE(SimplerNMSImpl, SimplerNMS); -//MKLDNN_EXTENSION_NODE(GRNImpl, GRN); +MKLDNN_EXTENSION_NODE(GRNImpl, GRN); //MKLDNN_EXTENSION_NODE(SparseFillEmptyRowsImpl, SparseFillEmptyRows); MKLDNN_EXTENSION_NODE(BucketizeImpl, Bucketize); MKLDNN_EXTENSION_NODE(CTCGreedyDecoderImpl, CTCGreedyDecoder); diff --git a/inference-engine/src/mkldnn_plugin/nodes/math.cpp b/inference-engine/src/mkldnn_plugin/nodes/math.cpp index a3907340bcf024..5649ffc1ed88ea 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/math.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/math.cpp @@ -280,6 +280,9 @@ std::map& op, MathImpl& node) { node.algorithm = MKLDNNPlugin::MathTan; + }}, + {ngraph::op::v3::Atanh::type_info, [](const std::shared_ptr& op, MathImpl& node) { + node.algorithm = MKLDNNPlugin::MathAtanh; }} }; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp index 5f94fcd26f5a58..517066d6f32806 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.cpp @@ -1093,23 +1093,10 @@ bool MKLDNNBinaryConvolutionNode::canFuse(const MKLDNNNodePtr& node) const { return false; if (node->getType() == FakeQuantize) { - return node->getAlgorithm() != FQBinarization; - } else if (node->getType() == Eltwise) { - // Only one Add operation can be fused since it is implemented via output blob reuse - if (node->getAlgorithm() == EltwiseAdd) { - for (auto& fusedNode : fusedWith) { - if (fusedNode->getType() == Eltwise && fusedNode->getAlgorithm() == EltwiseAdd) { - return false; - } - } - } - - return one_of(node->getAlgorithm(), EltwiseAdd, EltwiseMulAdd, EltwisePrelu, EltwiseRelu, EltwiseGelu, EltwiseElu, EltwiseSigmoid, EltwiseBoundedRelu, - EltwiseClamp, EltwiseTanh, EltwiseSwish, EltwiseHswish, EltwiseMish, EltwiseHsigmoid, EltwiseRoundHalfToEven, - EltwiseRoundHalfAwayFromZero, EltwiseLinear, EltwiseAbs, EltwiseSquare, EltwiseSqrt); + return node->getAlgorithm() == FQBinarization; + } else { + return canFuseSimpleOperation(node); } - - return false; } void MKLDNNBinaryConvolutionNode::setPostOps(mkldnn::primitive_attr &attr) { @@ -1118,7 +1105,7 @@ void MKLDNNBinaryConvolutionNode::setPostOps(mkldnn::primitive_attr &attr) { for (auto &node : fusedWith) { auto* eltwiseNode = dynamic_cast(node.get()); if (eltwiseNode) { - if (eltwiseNode->getAlgorithm() == EltwiseAdd) + if (eltwiseNode->isSpecialConvolutionAddFusing()) ops.append_sum(1.0); else eltwiseNode->appendPostOps(ops); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.h index 06eec46f0468f9..b8a93caf4c57b0 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_bin_conv_node.h @@ -90,6 +90,8 @@ class MKLDNNBinaryConvolutionNode : public MKLDNNNode { static bool isSupportedOperation(const std::shared_ptr& op, std::string& errorMessage) noexcept; + impl_desc_type getImplType() { return implType; } + private: bool withSum = false; bool withBinarization = false; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_concat_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_concat_node.cpp index e9c7091f1188f4..aa9d7b8fd9850a 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_concat_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_concat_node.cpp @@ -50,7 +50,7 @@ MKLDNNConcatNode::MKLDNNConcatNode(const std::shared_ptr& op, cons auto concatOp = ngraph::as_type_ptr(op); auto axis = concatOp->get_axis(); if (axis < 0) { - this->axis = concatOp->get_input_shape(0).size() - axis; + this->axis = concatOp->get_input_shape(0).size() + axis; } else { this->axis = axis; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp index 4d9f0544e75b6e..0b2e1336f9fa58 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.cpp @@ -724,6 +724,10 @@ MKLDNNMemoryDesc MKLDNNConvolutionNode::getSrcMemDesc(mkldnn::primitive_desc_ite } } +bool MKLDNNConvolutionNode::canFuse(const MKLDNNNodePtr& node) const { + return canFuseSimpleOperation(node); +} + InferenceEngine::Precision MKLDNNConvolutionNode::getRuntimePrecision() const { std::vector inputPrecisions; // Don't take bias precision into account diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.h index 58527200da3a9a..10c4755230a48f 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_conv_node.h @@ -50,6 +50,8 @@ class MKLDNNConvolutionNode : public MKLDNNNode { const std::vector &getPaddingL() { return paddingL; } const std::vector &getPaddingR() { return paddingR; } + bool canFuse(const MKLDNNNodePtr& node) const override; + protected: InferenceEngine::Precision fusedEltwisePrecision(const MKLDNNNodePtr& fusingNode) const; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp index c0b7101cdc7178..d226dd73890ec6 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.cpp @@ -35,6 +35,15 @@ MKLDNNConvertNode::MKLDNNConvertNode(const std::shared_ptr& op, co } } +MKLDNNConvertNode::MKLDNNConvertNode(const InferenceEngine::SizeVector &dims, const InferenceEngine::Precision &inPrc, const InferenceEngine::Precision &outPrc, + const std::string &nodeName, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) + : MKLDNNNode("Convert", nodeName, eng, cache) { + inDims.emplace_back(dims); + addOriginalInputPrecision(inPrc); + outDims.emplace_back(dims); + addOriginalOutputPrecision(outPrc); +} + void MKLDNNConvertNode::getSupportedDescriptors() { // if tensor descriptors are set via setDescs method we need to update the inDims/outDims data // from correspond tensor descriptors. diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h index 883fe68215f52f..6aacf7f1e5af96 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_convert_node.h @@ -14,6 +14,8 @@ namespace MKLDNNPlugin { class MKLDNNConvertNode : public MKLDNNNode { public: MKLDNNConvertNode(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache); + MKLDNNConvertNode(const InferenceEngine::SizeVector &dims, const InferenceEngine::Precision &inPrc, const InferenceEngine::Precision &outPrc, + const std::string &nodeName, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache); ~MKLDNNConvertNode() override = default; void getSupportedDescriptors() override; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp index f91e09c71226a6..b18763f0e5e6e3 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_deconv_node.cpp @@ -105,7 +105,7 @@ void MKLDNNDeconvolutionNode::getSupportedDescriptors() { IE_THROW() << errorPrefix << " has incorrect number of output edges"; for (int i = 0; i < paddingR.size(); i++) { - int with_group = (withGroups) ? 1 : 0; + int with_group = getAlgorithm() == DeconvolutionGrouped ? 1 : 0; int krn = weightDims[with_group + 2 + i]; int src = getChildEdgeAt(0)->getDims()[2 + i]; int dst = getParentEdgeAt(0)->getDims()[2 + i]; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.cpp index b3b1f4e6d830ce..6a29c0385da615 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_eltwise_node.cpp @@ -28,6 +28,7 @@ #include #include "ngraph_transformations/op/power_static.hpp" #include "ngraph_transformations/op/leaky_relu.hpp" +#include "ngraph_transformations/op/swish_cpu.hpp" #include #include @@ -900,21 +901,11 @@ std::map& op, MKLDNNEltwiseNode& node) { - auto swishOp = getNgraphOpAs(op); - if (swishOp->get_input_size() == 2) { - auto alphaConstOp = ngraph::as_type_ptr(swishOp->get_input_node_shared_ptr(1)); - if (!alphaConstOp) { - IE_THROW(NotImplemented) - << "CPU Eltwise node doesn't support ngraph operation Swish with dynamic second input"; - } - - node.alpha = alphaConstOp->cast_vector()[0]; - } else { - node.alpha = 1.0f; - } + {SwishNode::type_info, [](const std::shared_ptr& op, MKLDNNEltwiseNode& node) { + auto swishOp = getNgraphOpAs(op); node.algorithm = EltwiseSwish; node.mkldnnAlgorithm = mkldnn::algorithm::eltwise_swish; + node.alpha = swishOp->get_alpha(); }}, {ngraph::op::v4::HSwish::type_info, [](const std::shared_ptr& op, MKLDNNEltwiseNode& node) { node.algorithm = EltwiseHswish; @@ -1769,7 +1760,7 @@ void MKLDNNEltwiseNode::fillScalesAndShifts(const MKLDNNNode *parentNode) { void MKLDNNEltwiseNode::fuseInto(MKLDNNNodePtr& parentNode) { // Handling Convolution custom Add node fusing case which is processed via dnnl append_sum() API. - specialConvolutionAddFusing = parentNode->getType() == Convolution && getAlgorithm() == EltwiseAdd && + specialConvolutionAddFusing = (parentNode->getType() == Convolution || parentNode->getType() == BinaryConvolution) && getAlgorithm() == EltwiseAdd && getParentEdgesAtPort(0)[0]->getDims().ToSizeVector() == getParentEdgesAtPort(1)[0]->getDims().ToSizeVector(); if (!specialConvolutionAddFusing && canBePerformedAsScaleShift(parentNode.get())) { fillScalesAndShifts(parentNode.get()); diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp index 8ed6de26f54aec..35f9e6867e0490 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.cpp @@ -33,7 +33,6 @@ MKLDNNInputNode::MKLDNNInputNode(const std::shared_ptr& op, const IE_THROW(NotImplemented) << "CPU Input node doesn't support ngraph operation " << op->get_type_name() << " with name " << op->get_friendly_name(); constant = ConstantType::NoConst; - constBlob = nullptr; auto constOp = ngraph::as_type_ptr(op); if (constOp) { @@ -56,6 +55,19 @@ MKLDNNInputNode::MKLDNNInputNode(const std::shared_ptr& op, const } } +MKLDNNInputNode::MKLDNNInputNode(const InferenceEngine::SizeVector &dims, const InferenceEngine::Precision &prc, const std::string &name, + const std::string &type, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache) + : MKLDNNNode(type, name, eng, cache) { + constant = ConstantType::NoConst; + if (getType() == Input) { + outDims.emplace_back(dims); + addOriginalOutputPrecision(prc); + } else if (getType() == Output) { + inDims.emplace_back(dims); + addOriginalInputPrecision(prc); + } +} + void MKLDNNInputNode::getSupportedDescriptors() { if (getType() == Input) { if (!getParentEdges().empty()) diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h index 6761f9e0ed6cad..fa1cc0c49c3467 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_input_node.h @@ -13,6 +13,8 @@ namespace MKLDNNPlugin { class MKLDNNInputNode : public MKLDNNNode { public: MKLDNNInputNode(const std::shared_ptr& op, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache); + MKLDNNInputNode(const InferenceEngine::SizeVector &dims, const InferenceEngine::Precision &prc, const std::string &name, + const std::string &type, const mkldnn::engine& eng, MKLDNNWeightsSharing::Ptr &cache); ~MKLDNNInputNode() override = default; void getSupportedDescriptors() override; @@ -32,7 +34,7 @@ class MKLDNNInputNode : public MKLDNNNode { private: InferenceEngine::Precision precision; - InferenceEngine::Blob::Ptr constBlob; + InferenceEngine::Blob::Ptr constBlob = nullptr; bool isMeanImage = false; }; diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp index 2e685aa5617330..edbd4e426b1fd1 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_mvn_node.cpp @@ -677,7 +677,7 @@ MKLDNNMVNNode::MKLDNNMVNNode(const std::shared_ptr& op, const mkld epsValue_ = mvnOp->get_eps(); epsMode_ = INSIDE_SQRT; if (mvnOp->get_eps_mode() == ngraph::op::MVNEpsMode::OUTSIDE_SQRT) { - epsMode_ = INSIDE_SQRT; + epsMode_ = OUTSIDE_SQRT; } acrossChannels_ = false; @@ -1392,7 +1392,7 @@ bool MKLDNNMVNNode::canFuse(const MKLDNNNodePtr& node) const { return false; } - return canFuseSimpleOperation(node); + return canFuseSimpleOperation(node); } bool MKLDNNMVNNode::created() const { diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp index 6cee2582f7f937..ff95f416573a25 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_normalize_node.cpp @@ -654,7 +654,7 @@ MKLDNNNormalizeL2Node::MKLDNNNormalizeL2Node(const std::shared_ptr across_spatial = ngraph::shape_size(op->get_input_shape(AXES)) != 1; // One of the corner cases is when axes is an empty list, // then we divide each input element by itself resulting value 1 for all non-zero elements - cornerCase = op->get_input_shape(AXES).empty(); + cornerCase = ngraph::shape_size(op->get_input_shape(AXES)) == 0; } else { IE_THROW(NotImplemented) << errorMessage; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_pad_node.cpp b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_pad_node.cpp index a7fcac8aa03aaf..b4ef82481ca20d 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/mkldnn_pad_node.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/mkldnn_pad_node.cpp @@ -38,6 +38,13 @@ bool MKLDNNPadNode::isSupportedOperation(const std::shared_ptr& op errorMessage = "Has unsupported pad_mode: " + ngraph::as_string(pad_mode); return false; } + const auto pb = pad->get_pads_begin(); + const auto pe = pad->get_pads_end(); + if (std::count_if(pb.begin(), pb.end(), [](ptrdiff_t x) { return x < 0; }) != 0 || + std::count_if(pe.begin(), pe.end(), [](ptrdiff_t x) { return x < 0; }) != 0) { + errorMessage = "Doesn't support 'pads_begin' or 'pads_end' negative value"; + return false; + } } catch (...) { return false; } diff --git a/inference-engine/src/mkldnn_plugin/nodes/psroi_pooling.cpp b/inference-engine/src/mkldnn_plugin/nodes/psroi_pooling.cpp index ddc2b9e39eadcf..7feb71fb79b0c8 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/psroi_pooling.cpp +++ b/inference-engine/src/mkldnn_plugin/nodes/psroi_pooling.cpp @@ -63,11 +63,11 @@ class PSROIPoolingImpl: public ExtLayerBase { noTrans = op->get_input_size() == 2; if (op->get_input_shape(0).size() != 4) - IE_THROW() << errorPrefix << " has first input with incorrect rank: " + op->get_input_shape(0).size(); + IE_THROW() << errorPrefix << " has first input with incorrect rank: " + std::to_string(op->get_input_shape(0).size()); if (op->get_input_shape(1).size() != 2) - IE_THROW() << errorPrefix << " has second input with incorrect rank: " + op->get_input_shape(1).size(); + IE_THROW() << errorPrefix << " has second input with incorrect rank: " + std::to_string(op->get_input_shape(1).size()); if (!noTrans && op->get_input_shape(2).size() != 4) - IE_THROW() << errorPrefix << " has third input with incorrect rank: " + op->get_input_shape(2).size(); + IE_THROW() << errorPrefix << " has third input with incorrect rank: " + std::to_string(op->get_input_shape(2).size()); if (psroi) { if (psroi->get_input_size() != 2) diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp deleted file mode 100644 index b3bfd41267d3ef..00000000000000 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/add_output.cpp +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "behavior/add_output.hpp" -#include "functional_test_utils/test_model/test_model.hpp" -#include "functional_test_utils/plugin_cache.hpp" - -InferenceEngine::CNNNetwork getTargetNetwork() { - auto model = FuncTestUtils::TestModel::getModelWithMemory(InferenceEngine::Precision::FP32); - auto ie = PluginCache::get().ie(); - return ie->ReadNetwork(model.model_xml_str, model.weights_blob); -} - -std::vector testCases = { - addOutputsParams(getTargetNetwork(), {"Memory_1"}, CommonTestUtils::DEVICE_CPU) -}; - -INSTANTIATE_TEST_CASE_P(smoke_AddOutputBasic, AddOutputsTest, - ::testing::ValuesIn(testCases), - AddOutputsTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/memory_states.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/memory_states.cpp deleted file mode 100644 index 548c7d05311ca7..00000000000000 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/behavior/memory_states.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include "behavior/memory_states.hpp" -#include "functional_test_utils/test_model/test_model.hpp" -#include "functional_test_utils/plugin_cache.hpp" - -InferenceEngine::CNNNetwork getNetwork() { - auto model = FuncTestUtils::TestModel::getModelWithMultipleMemoryConnections(InferenceEngine::Precision::FP32); - auto ie = PluginCache::get().ie(); - return ie->ReadNetwork(model.model_xml_str, model.weights_blob); -} -std::vector memoryStateTestCases = { - memoryStateParams(getNetwork(), {"c_1-3", "r_1-3"}, CommonTestUtils::DEVICE_CPU) -}; - -INSTANTIATE_TEST_CASE_P(smoke_VariableStateBasic, VariableStateTest, - ::testing::ValuesIn(memoryStateTestCases), - VariableStateTest::getTestCaseName); diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp index 2ddda8ae6a18c8..f95ba68b777ddf 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/execution_graph_tests/runtime_precision.cpp @@ -19,7 +19,7 @@ const std::vector params = { {makeEltwiseFunction, {Precision::BF16, Precision::BF16}, {{"Eltwise", Precision::BF16}}}, {makeEltwiseFunction, {Precision::U8, Precision::U8}, {{"Eltwise", Precision::U8}}}, {makeEltwiseFunction, {Precision::I8, Precision::I8}, {{"Eltwise", Precision::I8}}}, - {makeFakeQuantizeReluFunction, {Precision::FP32}, {{"FakeQuantize", Precision::FP32}, {"Relu", Precision::U8}}}, + {makeFakeQuantizeReluFunction, {Precision::FP32}, {{"FakeQuantize", Precision::FP32}, {"Relu_original", Precision::U8}}}, {makeFakeQuantizeReluFunction, {Precision::U8}, {{"FakeQuantize", Precision::U8}, {"Relu", Precision::U8}}}, {makeFakeQuantizeBinaryConvolutionFunction, {Precision::FP32}, {{"FakeQuantize", Precision::FP32}, {"BinaryConvolution", Precision::BIN}}}, }; diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp index a5ea8e79bd4654..baf025aefacca9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/depth_to_space_transformation.cpp @@ -34,7 +34,7 @@ const auto DepthToSpaceBS2 = ::testing::Combine( ::testing::Values(2) ); -INSTANTIATE_TEST_CASE_P(DISABLED_LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_CASE_P(LPT_BS2, DepthToSpaceTransformation, DepthToSpaceBS2, DepthToSpaceTransformation::getTestCaseName); const std::vector inputShapesBS3 = { {1, 9, 3, 3}, {2, 27, 5, 4} @@ -48,5 +48,5 @@ const auto DepthToSpaceBS3 = ::testing::Combine( ::testing::Values(3) ); -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); +INSTANTIATE_TEST_CASE_P(smoke_LPT_BS3, DepthToSpaceTransformation, DepthToSpaceBS3, DepthToSpaceTransformation::getTestCaseName); } // namespace diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp index d3a34cd090d298..58caafc62f5dd9 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_transformation.cpp @@ -42,7 +42,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, MatMulTransformation, +INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(ngraph::Shape({ 1, 384, 1024 })), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp index f7d75e03d6809f..34e2dbf542d46b 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/low_precision_transformations/mat_mul_with_constant_transformation.cpp @@ -96,7 +96,7 @@ std::vector testValues = { } }; -INSTANTIATE_TEST_CASE_P(DISABLED_smoke_LPT, MatMulWithConstantTransformation, +INSTANTIATE_TEST_CASE_P(smoke_LPT, MatMulWithConstantTransformation, ::testing::Combine( ::testing::ValuesIn(precisions), ::testing::Values(CommonTestUtils::DEVICE_CPU), diff --git a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp index ae91176e0f28ef..9657f512a75e97 100644 --- a/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/cpu/shared_tests_instances/skip_tests_config.cpp @@ -55,6 +55,12 @@ std::vector disabledTestPatterns() { R"(.*ClampLayerTest.*netPrc=U64.*)", R"(.*CoreThreadingTestsWithIterations\.smoke_LoadNetwork.t.*)", + // incorrect reference implementation + R"(.*NormalizeL2LayerTest.*axes=\(\).*)", + // lpt transformation produce the same names for MatMul and Multiply + R"(.*MatMulTransformation.*)", + // incorrect jit_uni_planar_convolution with dilation = {1, 2, 1} and output channel 1 + R"(.*smoke_Convolution3D.*D=\(1.2.1\)_O=1.*)", /* ********************************************************** TEMPORARILY DISABLED TESTS ********************************************************** */ // shared SLT test @@ -68,59 +74,9 @@ std::vector disabledTestPatterns() { R"(.*RNNCellTest.*)", R"(.*RNNSequenceTest.*)", R"(.*TensorIteratorTest.*)", - R"(.*VariadicSplitPad.*)", - - // unsupported operation - // LPT_BS2/DepthToSpaceTransformation - // smoke_LPT_BS3/DepthToSpaceTransformation - R"(.*ExecGraphInputsFusingBinConv.*)", - - // dynamic batch - R"(.*ReshapeCheckDynBatch.*)", - R"(.*DynamicBatchTest.*)", - R"(.*InferConfigInTests.*)", // shared subgraph test R"(.*MultipleLSTMCellTest.*)", - - // shared behavior test, falied because QueryNetwork is not implemented - R"(.*smoke_QueryNetwork.*)", - R"(.*IEClassNetworkTestP.*)", - R"(.*IEClassImportExportTestP.*)", - R"(.*IEClassExecutableNetworkGetMetricTest.*)", - R"(.*IEClassHeteroExecutableNetworkGetMetricTest.*)", - R"(.*smoke_LoadNetwork.*)", - R"(.*QueryNetworkTest.*)", - - // plug-in specific tests - R"(.*GatherElementsCPUTest.*)", - R"(.*AddConvertToReorderTest.*)", - - // InferenceEngine::details::cloneNetwork requires ngraph-based `network` object to clone - R"(.*AddOutputsTest.*)", - - // serialize - R"(.*ExecGraphTests.*)", - R"(.*ExecGraphRuntimePrecision.*)", - R"(.*ExecGraphUniqueNodeNames.*)", - // smoke_LPT/MatMulTransformation - // smoke_LPT/MatMulWithConstantTransformation - - // input/output network - R"(.*NetWithLayout.*)", - R"(.*SetBlobOfKindTest.*)", - R"(.*PreprocessTest.*)", - ".*PreprocessConversionTest.*", - - R"(.*VariableStateTest.*)", - - // ******************************************** investigate ********************************************* - // accuracy difference - R"(.*smoke_Convolution3D.*)", - - // TEST: Node type name: "SoftMax" has not been found. - R"(.*SoftMaxLayerCPUTest.*)", - /* ******************************************************** END TEMPORARILY DISABLED TESTS ******************************************************** */ }; // TODO [NM]: Disabled until BF16 transformer is not migrated on CPU graph representation. diff --git a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp index 1bd230d091c39c..d672629ab0ca69 100644 --- a/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp +++ b/inference-engine/tests/functional/plugin/cpu/single_layer_tests/softmax.cpp @@ -74,7 +74,7 @@ TEST_P(SoftMaxLayerCPUTest, CompareWithRefs) { SKIP_IF_CURRENT_TEST_IS_DISABLED() Run(); - CheckPluginRelatedResults(executableNetwork, "SoftMax"); + CheckPluginRelatedResults(executableNetwork, "Softmax"); } namespace { diff --git a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/add_conver_to_reorder.cpp b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/add_conver_to_reorder.cpp index 9d572096250303..355bcdb613f36f 100644 --- a/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/add_conver_to_reorder.cpp +++ b/inference-engine/tests/functional/plugin/cpu/subgraph_tests/src/add_conver_to_reorder.cpp @@ -70,7 +70,7 @@ TEST_F(AddConvertToReorderTest, smoke_TestAddConvert_CPU) { BuildGraph(ngraph::element::bf16); Run(); CheckNodeOfTypeCount(executableNetwork, "Convert", 1); - CheckNodeOfTypeCount(executableNetwork, "Reorder", 0); + CheckNodeOfTypeCount(executableNetwork, "Reorder", 1); } /* Test insertion of the Reorder layer if there is one. @@ -91,7 +91,7 @@ TEST_F(AddConvertToReorderTest, smoke_TestAddReorder_CPU) { BuildGraph(ngraph::element::i8); Run(); CheckNodeOfTypeCount(executableNetwork, "Convert", 0); - CheckNodeOfTypeCount(executableNetwork, "Reorder", 1); + CheckNodeOfTypeCount(executableNetwork, "Reorder", 2); } } // namespace } // namespace LayerTestsDefinitions \ No newline at end of file diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp index b663f54859803f..6c92a9e45fad75 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp @@ -72,7 +72,7 @@ TEST_P(ExecGraphTests, CheckExecGraphInfoBeforeExecution) { const auto originalLayers = function->get_ops(); std::map originalLayersMap; for (const auto &layer : originalLayers) { - if (layer->description() == "Result") + if (layer->description() == "Result" && targetDevice != CommonTestUtils::DEVICE_CPU) continue; originalLayersMap[layer->get_friendly_name()] = 0; } diff --git a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp index 3e6e737e7b9893..60a785ac920db1 100644 --- a/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/low_precision_transformations/mat_mul_transformation.cpp @@ -92,6 +92,8 @@ void MatMulTransformation::validate() { } void MatMulTransformation::Run() { + SKIP_IF_CURRENT_TEST_IS_DISABLED() + LayerTestsCommon::Run(); const auto params = std::get<3>(GetParam()); diff --git a/ngraph/python/tests/__init__.py b/ngraph/python/tests/__init__.py index e579d02dfa094b..e4f80ba4025cf5 100644 --- a/ngraph/python/tests/__init__.py +++ b/ngraph/python/tests/__init__.py @@ -121,6 +121,7 @@ def xfail_test(reason="Mark the test as expected to fail", strict=True): xfail_issue_47323 = xfail_test(reason="RuntimeError: The plugin does not support FP64") xfail_issue_47337 = xfail_test(reason="RuntimeError: Unsupported dynamic ops: v1::OneHot") xfail_issue_33593 = xfail_test(reason="Current implementation of MaxPool doesn't support indices output") +xfail_issue_51993 = xfail_test(reason="PRelu supports only 1D tensor for 'slope' input broadcasted by channel") # Model MSFT issues: xfail_issue_37957 = xfail_test(reason="RuntimeError: nGraph does not support the following ONNX operations:" diff --git a/ngraph/python/tests/test_onnx/test_backend.py b/ngraph/python/tests/test_onnx/test_backend.py index e508551b2c0418..683146ae542307 100644 --- a/ngraph/python/tests/test_onnx/test_backend.py +++ b/ngraph/python/tests/test_onnx/test_backend.py @@ -61,7 +61,8 @@ xfail_issue_49752, xfail_issue_49753, xfail_issue_49754, - xfail_issue_52463) + xfail_issue_52463, + xfail_issue_51993) def expect_fail(test_case_path, xfail): # type: (str) -> None @@ -391,6 +392,8 @@ def expect_fail(test_case_path, xfail): # type: (str) -> None (xfail_issue_33593, "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_strides_cpu", "OnnxBackendNodeModelTest.test_maxpool_with_argmax_2d_precomputed_pads_cpu",), + (xfail_issue_51993, + "OnnxBackendNodeModelTest.test_prelu_broadcast_cpu",) ] for test_group in tests_expected_to_fail: diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index a5de02359ee577..e0fb314f1e96f3 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -2913,7 +2913,8 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_model_instance_normalization) 1.0739619f, 1.6918856f, 2.3098092f, 2.927733f, 3.5456567f, 4.1635804f, -4.130463f, -3.1876516f, -2.2448401f, -1.3020288f, -0.35921717f, 0.5835942f, 1.5264057f, 2.469217f, 3.4120288f, 4.35484f, 5.2976513f, 6.240463f}); - test_case.run(); + const size_t tolerance_bits = 3; + test_case.run(tolerance_bits); } NGRAPH_TEST(${BACKEND_NAME}, onnx_instance_normalization_dynamic) diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 71693b715e26e0..1797f6bfb3675f 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1666,55 +1666,3 @@ IE_CPU.deformable_convolution_2D_integral_offsets_groups_and_deforgroups IE_CPU.deformable_convolution_2D_real_offsets_groups_basic IE_CPU.deformable_convolution_2D_real_offsets_groups_complex IE_CPU.deformable_convolution_2D_real_offsets_groups_and_deforgroups - -# CPU NGRAPH MIGRATION -IE_CPU.concat_negative_axis -IE_CPU.grn_4d -IE_CPU.group_convolution_backprop_data_1D_1group_1batch_1channel -IE_CPU.group_convolution_backprop_data_2D -IE_CPU.group_convolution_backprop_data_2D_output_shape -IE_CPU.normalize_l2_one_mode_add -IE_CPU.normalize_l2_one_mode_max -IE_CPU.onnx_model_atanh -IE_CPU.onnx_model_instance_normalization -IE_CPU.onnx_controlflow_loop_2d_add -IE_CPU.onnx_controlflow_loop_2d_no_identity_termination_cond_static_shapes -IE_CPU.onnx_controlflow_loop_2d_const_no_identity_termination_cond_static_shapes -IE_CPU.onnx_controlflow_loop_2d_both_cond_and_trip_count_as_inputs_static_shapes -IE_CPU.onnx_controlflow_loop_add_initializer_from_parent_scope -IE_CPU.onnx_controlflow_loop_add_node_from_parent_scope -IE_CPU.onnx_controlflow_loop_add_node_from_parent_scope_used_in_parent_and_in_body -IE_CPU.onnx_controlflow_loop_add_value_the_same_node_from_parent_and_subgraph -IE_CPU.onnx_controlflow_loop_add_input_from_parent_graph -IE_CPU.onnx_controlflow_loop_scalars -IE_CPU.onnx_controlflow_loop_2d_add_const_cond -IE_CPU.onnx_model_swish_with_beta -IE_CPU.onnx_model_swish_without_beta -IE_CPU.onnx_model_concat_negative_axis -IE_CPU.onnx_model_lstm_fwd_default_const -IE_CPU.onnx_model_lstm_reverse_const -IE_CPU.onnx_model_lstm_bidir_const -IE_CPU.onnx_model_lstm_fwd_with_clip_const -IE_CPU.onnx_model_lstm_fwd_mixed_seq_const -IE_CPU.onnx_model_lstm_reverse_mixed_seq_const -IE_CPU.onnx_model_lstm_bidir_mixed_seq_const -IE_CPU.onnx_model_lstm_dynamic_batch_size_and_seq_len -IE_CPU.onnx_model_gru_defaults_fwd_const -IE_CPU.onnx_model_gru_fwd_activations_const -IE_CPU.onnx_model_gru_fwd_mixed_seq_len_const -IE_CPU.onnx_model_gru_reverse_mixed_seq_len_const -IE_CPU.onnx_model_gru_bidir_mixed_seq_len_const -IE_CPU.onnx_model_gru_rev_clip_const -IE_CPU.onnx_model_gru_reverse_const -IE_CPU.onnx_model_gru_fwd_bias_initial_h_const -IE_CPU.onnx_model_gru_bidirectional_const -IE_CPU.onnx_model_gru_fwd_linear_before_reset_const -IE_CPU.onnx_model_rnn_defaults_fwd_const -IE_CPU.onnx_model_rnn_fwd_activations_const -IE_CPU.onnx_model_rnn_fwd_mixed_seq_len_const -IE_CPU.onnx_model_rnn_reverse_mixed_seq_len_const -IE_CPU.onnx_model_rnn_bidir_mixed_seq_len_const -IE_CPU.onnx_model_rnn_rev_clip_const -IE_CPU.onnx_model_rnn_reverse_const -IE_CPU.onnx_model_rnn_fwd_bias_initial_h_const -IE_CPU.onnx_model_rnn_bidirectional_const