Skip to content

Commit

Permalink
other nodes enabled (#2)
Browse files Browse the repository at this point in the history
* memory, math, lrn, log softmax, interpolate enabled

* embedding and experimental enabled

* space_to_batch, grn, gather*, extract_image_patches, dft, detection_output, depth_to_space enabled

* proposal, pooling, def_conv enabled

* fullyconnected, matmul, softmax enabled

* matmul fusing tests

* fc, conv any format fixes

* rm extra deconv cmake

* review fixes

* review fixess
  • Loading branch information
Maxim Andronov authored and zhangYiIntel committed Jul 26, 2021
1 parent c178a20 commit cef541a
Show file tree
Hide file tree
Showing 57 changed files with 558 additions and 519 deletions.
62 changes: 60 additions & 2 deletions inference-engine/src/mkldnn_plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ file(GLOB SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/ngraph_transformations/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ngraph_transformations/op/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_split_node.cpp
# ${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_concat_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_reorder_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_input_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_eltwise_node.cpp
Expand Down Expand Up @@ -69,6 +68,36 @@ file(GLOB SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_mvn_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_cum_sum_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_deconv_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_memory_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_math_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_lrn_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_log_softmax_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_interpolate_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_detection_output_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_generate_proposals_single_image_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_priorgridgenerator_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_roifeatureextractor_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_topkrois_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_offset_sum_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_packed_sum_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_sum_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_segments_sum_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_space_to_batch_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_grn_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_tree_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_nd_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_elements_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_extract_image_patches_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_dft_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_detection_output_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_depth_to_space_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_proposal_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_softmax_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_fullyconnected_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_matmul_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_pooling_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_def_conv_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/proposal_imp.cpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/list.cpp
)
Expand All @@ -82,7 +111,6 @@ file(GLOB HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/utils/rt_info/*.hpp
# ${CMAKE_CURRENT_SOURCE_DIR}/nodes/*.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_split_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_concat_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_reorder_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_input_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_eltwise_node.h
Expand Down Expand Up @@ -125,6 +153,36 @@ file(GLOB HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_mvn_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_cum_sum_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_deconv_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_memory_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_math_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_lrn_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_log_softmax_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_interpolate_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_detection_output_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_generate_proposals_single_image_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_priorgridgenerator_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_roifeatureextractor_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_experimental_detectron_topkrois_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_offset_sum_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_packed_sum_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_bag_sum_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_embedding_segments_sum_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_space_to_batch_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_grn_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_tree_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_nd_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_gather_elements_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_extract_image_patches_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_dft_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_detection_output_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_depth_to_space_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_proposal_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_softmax_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_fullyconnected_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_matmul_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_pooling_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/mkldnn_def_conv_node.h
${CMAKE_CURRENT_SOURCE_DIR}/nodes/proposal_imp.hpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/base.hpp
${CMAKE_CURRENT_SOURCE_DIR}/nodes/common/*.h
Expand Down
21 changes: 10 additions & 11 deletions inference-engine/src/mkldnn_plugin/mkldnn_exec_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,16 @@ MKLDNNExecNetwork::MKLDNNExecNetwork(const InferenceEngine::CNNNetwork &network,
if (_graphs.size() == 1) {
for (auto &node : GetGraph()._graph.GetNodes()) {
if (node->getType() == MemoryInput) {
IE_THROW() << "[DS] Unimplemented";
// auto memoryNode = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
// auto state_store = memoryNode->getStore();
// auto state_name = memoryNode->getId();
//
// // Remove suffix with pair ID. Internal information.
// auto suffix_idx = state_name.find("/id=");
// if (suffix_idx != std::string::npos)
// state_name = state_name.substr(0, suffix_idx);
//
// memoryStates.emplace_back(new MKLDNNVariableState(state_name, state_store));
auto memoryNode = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
auto state_store = memoryNode->getStore();
auto state_name = memoryNode->getId();

// Remove suffix with pair ID. Internal information.
auto suffix_idx = state_name.find("/id=");
if (suffix_idx != std::string::npos)
state_name = state_name.substr(0, suffix_idx);

memoryStates.emplace_back(new MKLDNNVariableState(state_name, state_store));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

#include "mkldnn_extension_utils.h"
#include "utils/general_utils.h"
#include "cpu_memory_desc_utils.h"
#include <limits>
#include <vector>
#include <numeric>
Expand Down
1 change: 0 additions & 1 deletion inference-engine/src/mkldnn_plugin/mkldnn_graph_dumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <ngraph/variant.hpp>
#include "ngraph/ngraph.hpp"
#include "utils/debug_capabilities.h"
#include "cpu_memory_desc_utils.h"
#include <vector>
#include <string>
#include <memory>
Expand Down
6 changes: 2 additions & 4 deletions inference-engine/src/mkldnn_plugin/mkldnn_graph_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,10 +1200,8 @@ void MKLDNNGraphOptimizer::FuseInterpolateAndSimpleOperation(MKLDNNGraph &graph)
}
if (!childNode->getFusedWith().empty())
return false;
// TODO [mkutako]: uncomment
// auto interpolateNode = dynamic_cast<MKLDNNInterpolateNode*>(parentNode.get());
// return interpolateNode->canFuse(childNode);
return false;
auto interpolateNode = dynamic_cast<MKLDNNInterpolateNode*>(parentNode.get());
return interpolateNode->canFuse(childNode);
};

auto parent = graphNodes.begin();
Expand Down
71 changes: 34 additions & 37 deletions inference-engine/src/mkldnn_plugin/mkldnn_infer_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,16 @@ MKLDNNPlugin::MKLDNNInferRequest::MKLDNNInferRequest(InferenceEngine::InputsData
if (execNetwork->_numRequests > 1 || execNetwork->QueryState().size() == 0) {
for (auto &node : graph->GetNodes()) {
if (node->getType() == MemoryInput) {
IE_THROW() << "[DS] Unimplemented";
// auto memoryNode = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
// auto state_store = memoryNode->getStore();
// auto state_name = memoryNode->getId();
//
// // Remove suffix with pair ID. Internal information.
// auto suffix_idx = state_name.find("/id=");
// if (suffix_idx != std::string::npos)
// state_name = state_name.substr(0, suffix_idx);
//
// memoryStates.emplace_back(new MKLDNNVariableState(state_name, state_store));
auto memoryNode = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
auto state_store = memoryNode->getStore();
auto state_name = memoryNode->getId();

// Remove suffix with pair ID. Internal information.
auto suffix_idx = state_name.find("/id=");
if (suffix_idx != std::string::npos)
state_name = state_name.substr(0, suffix_idx);

memoryStates.emplace_back(new MKLDNNVariableState(state_name, state_store));
}
}
} else {
Expand Down Expand Up @@ -130,39 +129,37 @@ void MKLDNNPlugin::MKLDNNInferRequest::PushInputData() {
void MKLDNNPlugin::MKLDNNInferRequest::PushStates() {
for (auto &node : graph->GetNodes()) {
if (node->getType() == MemoryInput) {
IE_THROW() << "[DS] Unimplemented";
// auto cur_node = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
// auto cur_id = cur_node->getId();
// for (const auto& state : memoryStates) {
// if (state->GetName() == cur_id) {
// auto cur_state_mem = cur_node->getStore();
// auto data_ptr = state->GetState()->cbuffer().as<void*>();
// auto data_size = state->GetState()->byteSize();
// auto cur_state_mem_buf = static_cast<uint8_t*>(cur_state_mem->GetPtr());
//
// cpu_memcpy(cur_state_mem_buf, data_ptr, data_size);
// }
// }
auto cur_node = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
auto cur_id = cur_node->getId();
for (const auto& state : memoryStates) {
if (state->GetName() == cur_id) {
auto cur_state_mem = cur_node->getStore();
auto data_ptr = state->GetState()->cbuffer().as<void*>();
auto data_size = state->GetState()->byteSize();
auto cur_state_mem_buf = static_cast<uint8_t*>(cur_state_mem->GetPtr());

cpu_memcpy(cur_state_mem_buf, data_ptr, data_size);
}
}
}
}
}

void MKLDNNPlugin::MKLDNNInferRequest::PullStates() {
for (auto &node : graph->GetNodes()) {
if (node->getType() == MemoryInput) {
IE_THROW() << "[DS] Unimplemented";
// auto cur_node = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
// auto cur_id = cur_node->getId();
// for (const auto& state : memoryStates) {
// if (state->GetName() == cur_id) {
// auto cur_state_mem = cur_node->getStore();
// auto data_ptr = state->GetState()->cbuffer().as<void*>();
// auto data_size = state->GetState()->byteSize();
// auto cur_state_mem_buf = static_cast<uint8_t*>(cur_state_mem->GetPtr());
//
// cpu_memcpy(data_ptr, cur_state_mem_buf, data_size);
// }
// }
auto cur_node = dynamic_cast<MKLDNNMemoryInputNode*>(node.get());
auto cur_id = cur_node->getId();
for (const auto& state : memoryStates) {
if (state->GetName() == cur_id) {
auto cur_state_mem = cur_node->getStore();
auto data_ptr = state->GetState()->cbuffer().as<void*>();
auto data_size = state->GetState()->byteSize();
auto cur_state_mem_buf = static_cast<uint8_t*>(cur_state_mem->GetPtr());

cpu_memcpy(data_ptr, cur_state_mem_buf, data_size);
}
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions inference-engine/src/mkldnn_plugin/mkldnn_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,15 @@ bool MKLDNNMemoryDesc::checkGeneralLayout(GeneralLayout layoutType) const {
}

std::string MKLDNNMemoryDesc::serializeFormat() const {
if (desc.data.format_kind == dnnl_format_kind_wino) {
switch (desc.data.format_desc.wino_desc.wino_format) {
case dnnl_wino_memory_format_t::dnnl_wino_wei_aaOIoi: return "wino_aaOIoi";
case dnnl_wino_memory_format_t::dnnl_wino_wei_aaOio: return "wino_aaOio";
case dnnl_wino_memory_format_t::dnnl_wino_wei_aaOBiOo: return "wino_aaOBiOo";
case dnnl_wino_memory_format_t::dnnl_wino_wei_OBaaIBOIio: return "wino_OBaaIBOIio";
default: return "wino_undef";
}
}
auto fmt = getFormat();
return mkldnn::utils::fmt2str(fmt);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <mkldnn_selective_build.h>
#include "mkldnn_batch_to_space_node.h"
#include <nodes/common/blocked_desc_creator.h>
#include <cpu_memory_desc_utils.h>
#include <ngraph/opsets/opset2.hpp>

using namespace MKLDNNPlugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "cpu/x64/cpu_isa_traits.hpp"
#include "utils/general_utils.h"
#include <ngraph/opsets/opset1.hpp>
#include <cpu_memory_desc_utils.h>

// WA for xbyak.h
#ifdef _WIN32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <nodes/common/blocked_desc_creator.h>
#include <ngraph/opsets/opset1.hpp>
#include "common/cpu_memcpy.h"
#include <cpu_memory_desc_utils.h>

using namespace MKLDNNPlugin;
using namespace InferenceEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void MKLDNNConcatNode::selectOptimalPrimitiveDescriptor() {

size_t maxCount = 0;
auto outDims = getChildEdgeAt(0)->getShape().getStaticDims();
GeneralLayout convertTo;
GeneralLayout convertTo = GeneralLayout::ncsp;
for (auto &it : formatFrequency) {
if (it.second > maxCount) {
maxCount = it.second;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "ie_precision.hpp"
#include <ie_ngraph_utils.hpp>
#include "mkldnn_cum_sum_node.h"
#include "cpu_memory_desc_utils.h"

using namespace MKLDNNPlugin;
using namespace InferenceEngine;
Expand Down
Loading

0 comments on commit cef541a

Please sign in to comment.