Update nGraph to version 0.26 (#1965)

* Adjust ngraph cmake files to onnx 1.5.0

* Enable LSTM reverse direction mode in nGraph EP

* Enable full support for the Split op in nGraph EP

* Revert "Disable the unsigned input Shrink op tests for nGraph until the next update"

This reverts commit 257b42a55bdd98f804d4846868542b8e3aeb4b4e.

* Enable Gather and remove unused subgraph attribute

* Remove the unused param from AppendClusterToSubGraph

* Fix for the incorrect onnx opset version

* Use the r0.26 release branch before the tag is created

* Enable the quantizelinear and dequantizelinear for NGEP

* Use the v0.26.0-rc.2 tag in ngraph.cmake

* Add skip for modes others than default in Pad operator

* Reenable negative axis tests for ngraph

* Use temporary ngraph version

* Use branch name instead of SHA for temporary ngraph branch

* Use ngraph v0.26.0-rc.4

* Remove patch for missing symbol in MKLDNN

* Use MKLDNN 1.0 in ngraph

* Exclude the Pad op for opsets greater than 10

* Disable quantizelinear and dequantizelinear tests for ONNX 1.5.0

* Fix the onnx-headers related compilation errors

* ONNX libs linking fix

* Use a tag for ngraph and support more Pad modes

* Use the v0.26.0 release tag for nGraph

* Update ngraph to RC8 - bigobj flag for Windows builds

* Fix the MKLDNN constexpr error on Windows
This commit is contained in:
Tomasz Socha 2019-10-14 19:37:48 +02:00 committed by George Wu
parent 91db840b6b
commit f93be8af90
10 changed files with 109 additions and 302 deletions

View file

@ -9,9 +9,9 @@ set(ngraph_INCLUDE_DIRS ${ngraph_INSTALL_DIR}/include)
set(ngraph_LIBRARIES ${ngraph_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR})
set(ngraph_SRC ${CMAKE_CURRENT_BINARY_DIR}/ngraph/src/project_ngraph)
set(prebuilt_ONNX_SOURCE_DIR "${PROJECT_SOURCE_DIR}/external/onnx")
set(prebuilt_ONNX_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/onnx")
set(prebuilt_ONNX_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
set(ngraph_URL "https://github.com/NervanaSystems/ngraph.git")
set(ngraph_TAG "v0.22.1")
set(ngraph_TAG "v0.26.0")
# Libraries for python package.
if (WIN32)
@ -45,21 +45,17 @@ endif()
set(NGRAPH_PATCH_DISCARD_COMMAND cd ${ngraph_SRC} && git reset HEAD --hard && git clean -fx)
if (MSVC)
set(prebuilt_ONNX_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/onnx/${CMAKE_BUILD_TYPE}")
set(prebuilt_ONNX_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
# For the moment, Windows does not support codegen, it works on DEX-only mode
ExternalProject_Add(project_ngraph
PREFIX ngraph
GIT_REPOSITORY ${ngraph_URL}
GIT_TAG ${ngraph_TAG}
GIT_SHALLOW TRUE
GIT_CONFIG core.autocrlf=input
PATCH_COMMAND ${NGRAPH_PATCH_DISCARD_COMMAND}
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/patches/ngraph/ngraph_onnx.cmake ${ngraph_SRC}/cmake/external_onnx.cmake
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/ngraph/ngraph_protobuf.patch
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/ngraph/ngraph_fix_memory.patch
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/ngraph/ngraph_fix_mkldnn_missing_symbol.patch
COMMAND git apply --ignore-space-change --ignore-whitespace ${PROJECT_SOURCE_DIR}/patches/ngraph/mkldnn_constexpr.patch
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DNGRAPH_DEX_ONLY=ON
@ -69,6 +65,7 @@ if (MSVC)
-DNGRAPH_ONNXIFI_ENABLE=FALSE
-DNGRAPH_UNIT_TEST_ENABLE=FALSE
-DNGRAPH_TOOLS_ENABLE=FALSE
-DNGRAPH_USE_LEGACY_MKLDNN=FALSE
-DCMAKE_INSTALL_PREFIX=${ngraph_INSTALL_DIR}
-Dprebuilt_ONNX_BINARY_DIR=${prebuilt_ONNX_BINARY_DIR}
-Dprebuilt_ONNX_SOURCE_DIR=${prebuilt_ONNX_SOURCE_DIR}
@ -96,6 +93,7 @@ else()
-DNGRAPH_ONNXIFI_ENABLE=FALSE
-DNGRAPH_UNIT_TEST_ENABLE=FALSE
-DNGRAPH_TOOLS_ENABLE=FALSE
-DNGRAPH_USE_LEGACY_MKLDNN=FALSE
-DCMAKE_INSTALL_PREFIX=${ngraph_INSTALL_DIR}
-Dprebuilt_ONNX_BINARY_DIR=${prebuilt_ONNX_BINARY_DIR}
-Dprebuilt_ONNX_SOURCE_DIR=${prebuilt_ONNX_SOURCE_DIR}

View file

@ -0,0 +1,61 @@
diff --git a/cmake/external_mkldnn_v1.cmake b/cmake/external_mkldnn_v1.cmake
index fb77250c..d72d1b6c 100644
--- a/cmake/external_mkldnn_v1.cmake
+++ b/cmake/external_mkldnn_v1.cmake
@@ -200,6 +200,7 @@ if (WIN32)
CONFIGURE_COMMAND
PATCH_COMMAND ${MKLDNN_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/${MKLDNN_PATCH_FILE}
+ COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/mkldnn_constexpr.patch
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
diff --git a/cmake/mkldnn_constexpr.patch b/cmake/mkldnn_constexpr.patch
new file mode 100644
index 00000000..86e99cc8
--- /dev/null
+++ b/cmake/mkldnn_constexpr.patch
@@ -0,0 +1,43 @@
+diff --git a/src/cpu/rnn/rnn_reorders.hpp b/src/cpu/rnn/rnn_reorders.hpp
+index fbfedd01..786d4f8f 100644
+--- a/src/cpu/rnn/rnn_reorders.hpp
++++ b/src/cpu/rnn/rnn_reorders.hpp
+@@ -128,7 +128,7 @@ struct rnn_weights_reorder_t : public cpu_primitive_t {
+ return status::success;
+ }
+
+- format_tag_t itag_;
++ format_tag_t itag_ = mkldnn_format_tag_undef;
+
+ private:
+ void init_scratchpad() {
+diff --git a/src/cpu/simple_concat.hpp b/src/cpu/simple_concat.hpp
+index fe84eb14..f1b2bd17 100644
+--- a/src/cpu/simple_concat.hpp
++++ b/src/cpu/simple_concat.hpp
+@@ -98,9 +98,9 @@ struct simple_concat_t: public cpu_primitive_t {
+ return status::success;
+ }
+
+- int perm_[MKLDNN_MAX_NDIMS];
+- int iperm_[MKLDNN_MAX_NDIMS];
+- dims_t blocks_;
++ int perm_[MKLDNN_MAX_NDIMS] {};
++ int iperm_[MKLDNN_MAX_NDIMS] {};
++ dims_t blocks_ {};
+
+ dim_t nelems_to_concat(const memory_desc_wrapper &data_d) const {
+ const int ndims = data_d.ndims();
+diff --git a/src/cpu/simple_sum.hpp b/src/cpu/simple_sum.hpp
+index 46a24810..c5376eab 100644
+--- a/src/cpu/simple_sum.hpp
++++ b/src/cpu/simple_sum.hpp
+@@ -71,7 +71,7 @@ struct simple_sum_t: public cpu_primitive_t {
+ }
+
+ sum_bf16_params_t bf16_p_;
+- dim_t block_size_, nelems_, blocks_number_, tail_;
++ dim_t block_size_ = 0, nelems_ = 0, blocks_number_ = 0, tail_ = 0;
+
+ private:
+ const dim_t cacheline_size_ = 64; // bytes

View file

@ -1,125 +0,0 @@
cmake/external_mkldnn.cmake | 1 +
cmake/mkldnn_fix_memory.patch | 99 +++++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 cmake/mkldnn_fix_memory.patch
diff --git a/cmake/external_mkldnn.cmake b/cmake/external_mkldnn.cmake
index 7874aca76..bbae6d1a4 100644
--- a/cmake/external_mkldnn.cmake
+++ b/cmake/external_mkldnn.cmake
@@ -194,6 +194,7 @@ if (WIN32)
CONFIGURE_COMMAND
PATCH_COMMAND ${MKLDNN_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/${MKLDNN_PATCH_FILE}
+ COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/mkldnn_fix_memory.patch
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
diff --git a/cmake/mkldnn_fix_memory.patch b/cmake/mkldnn_fix_memory.patch
new file mode 100644
index 000000000..ea1a3bd61
--- /dev/null
+++ b/cmake/mkldnn_fix_memory.patch
@@ -0,0 +1,99 @@
+ src/cpu/jit_avx2_1x1_convolution.cpp | 6 +++---
+ src/cpu/jit_avx512_common_1x1_convolution.cpp | 9 +++++----
+ src/cpu/jit_avx512_core_x8s8s32x_1x1_convolution.cpp | 2 +-
+ src/cpu/jit_uni_1x1_conv_utils.hpp | 1 +
+ 4 files changed, 10 insertions(+), 8 deletions(-)
+
+diff --git a/src/cpu/jit_avx2_1x1_convolution.cpp b/src/cpu/jit_avx2_1x1_convolution.cpp
+index 46362886..edb2b6fb 100644
+--- a/src/cpu/jit_avx2_1x1_convolution.cpp
++++ b/src/cpu/jit_avx2_1x1_convolution.cpp
+@@ -50,7 +50,7 @@ void jit_avx2_1x1_convolution_fwd_t::execute_forward() const {
+ const memory_desc_wrapper weights_d(pd()->weights_pd(0));
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad().get<data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad().get<data_t>(key_conv_rtus_space):NULL;
+
+ const int work_amount = jcp.mb * jcp.ngroups * jcp.nb_bcast;
+ const int ndims = dst_d.ndims();
+@@ -180,7 +180,7 @@ void jit_avx2_1x1_convolution_bwd_data_t::execute_backward_data() const {
+ const memory_desc_wrapper diff_src_d(pd()->diff_src_pd());
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad().get<data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad().get<data_t>(key_conv_rtus_space):NULL;
+
+ // TODO (Roma): remove this restriction
+ assert(jcp.stride_w == 1 && jcp.stride_h == 1);
+@@ -306,7 +306,7 @@ void jit_avx2_1x1_convolution_bwd_weights_t::execute_backward_weights() const {
+ const memory_desc_wrapper diff_bias_d(pd()->diff_weights_pd(1));
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad.get<data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad.get<data_t>(key_conv_rtus_space):NULL;
+
+ data_t *diff_bias = pd()->wants_padded_bias()
+ ? scratchpad.get<data_t>(key_conv_padded_bias) : diff_bias_in;
+diff --git a/src/cpu/jit_avx512_common_1x1_convolution.cpp b/src/cpu/jit_avx512_common_1x1_convolution.cpp
+index 6879cd91..47cea4f4 100644
+--- a/src/cpu/jit_avx512_common_1x1_convolution.cpp
++++ b/src/cpu/jit_avx512_common_1x1_convolution.cpp
+@@ -106,7 +106,7 @@ execute_forward_thr(const int ithr, const int nthr, const src_data_t *src,
+ const memory_desc_wrapper weights_d(pd()->weights_pd(0));
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad.get<src_data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad.get<src_data_t>(key_conv_rtus_space):NULL;
+
+ const int ndims = src_d.ndims();
+ const int stride_h = (ndims == 3) ? 1 : pd()->desc()->strides[0];
+@@ -301,8 +301,9 @@ void jit_avx512_common_1x1_convolution_bwd_data_t<diff_dst_type, wei_type,
+ const memory_desc_wrapper diff_src_d(pd()->diff_src_pd());
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad().template get<diff_src_data_t>(
+- key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_
++ ? scratchpad().template get<diff_src_data_t>(key_conv_rtus_space)
++ : NULL;
+
+ const int ndims = diff_src_d.ndims();
+
+@@ -470,7 +471,7 @@ void jit_avx512_common_1x1_convolution_bwd_weights_t::execute_backward_weights()
+
+ const auto scratchpad = this->scratchpad();
+
+- auto rtus_space = scratchpad.get<data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad.get<data_t>(key_conv_rtus_space):NULL;
+ data_t *diff_bias = pd()->wants_padded_bias()
+ ? scratchpad.get<data_t>(key_conv_padded_bias) : diff_bias_in;
+ auto wei_reduction = scratchpad.get<data_t>(key_conv_wei_reduction);
+diff --git a/src/cpu/jit_avx512_core_x8s8s32x_1x1_convolution.cpp b/src/cpu/jit_avx512_core_x8s8s32x_1x1_convolution.cpp
+index de303cd2..8129f2b2 100644
+--- a/src/cpu/jit_avx512_core_x8s8s32x_1x1_convolution.cpp
++++ b/src/cpu/jit_avx512_core_x8s8s32x_1x1_convolution.cpp
+@@ -100,7 +100,7 @@ void jit_avx512_core_x8s8s32x_1x1_convolution_fwd_t<src_type, dst_type>
+ ? types::data_type_size(pd()->desc()->bias_desc.data_type) : 0;
+
+ const auto &jcp = kernel_->jcp;
+- auto rtus_space = scratchpad.get<src_data_t>(key_conv_rtus_space);
++ auto rtus_space = pd()->rtus_.reduce_src_?scratchpad.get<src_data_t>(key_conv_rtus_space):NULL;
+ auto local_scales = scratchpad.get<float>(key_conv_adjusted_scales);
+
+ const int work_amount = jcp.mb * jcp.ngroups * jcp.nb_bcast;
+diff --git a/src/cpu/jit_uni_1x1_conv_utils.hpp b/src/cpu/jit_uni_1x1_conv_utils.hpp
+index a3ed769a..6d76ba56 100644
+--- a/src/cpu/jit_uni_1x1_conv_utils.hpp
++++ b/src/cpu/jit_uni_1x1_conv_utils.hpp
+@@ -94,6 +94,7 @@ inline void rtus_prepare(conv_pd_t *self, const convolution_desc_t *&conv_d,
+ template <typename conv_pd_t>
+ inline void rtus_prepare_space_info(conv_pd_t *self,
+ memory_tracking::registrar_t &scratchpad) {
++ if (!self->rtus_.reduce_src_) return;
+ const auto &jcp = self->jcp_;
+
+ const int max_threads = mkldnn_get_max_threads();
+--
+2.20.1.windows.1
+
--
2.20.1.windows.1

View file

@ -1,64 +0,0 @@
cmake/external_mkldnn.cmake | 1 +
cmake/mkldnn_fix_missing_symbol.patch | 99 +++++++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+)
create mode 100644 cmake/mkldnn_fix_missing_symbol.patch
diff --git a/cmake/external_mkldnn.cmake b/cmake/external_mkldnn.cmake
index 7874aca76..bbae6d1a4 100644
--- a/cmake/external_mkldnn.cmake
+++ b/cmake/external_mkldnn.cmake
@@ -194,7 +194,8 @@ if (WIN32)
CONFIGURE_COMMAND
PATCH_COMMAND ${MKLDNN_PATCH_REVERT_COMMAND}
COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/${MKLDNN_PATCH_FILE}
COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/mkldnn_fix_memory.patch
+ COMMAND git apply --ignore-space-change --ignore-whitespace ${CMAKE_SOURCE_DIR}/cmake/mkldnn_fix_missing_symbol.patch
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
diff --git a/cmake/mkldnn_fix_missing_symbol.patch b/cmake/mkldnn_fix_missing_symbol.patch
new file mode 100644
index 000000000..ea1a3bd61
--- /dev/null
+++ b/cmake/mkldnn_fix_missing_symbol.patch
@@ -0,0 +1,40 @@
+commit d485a54ac2b07b7349dabd833961415315a18fea
+Author: Denis Samoilov <denis.samoylov@intel.com>
+Date: Sun Apr 14 20:11:33 2019 -0700
+
+ cpu: gemv: fix unresolved symbol
+
+ Fixes #456
+
+diff --git a/src/cpu/gemm/gemm_driver.cpp b/src/cpu/gemm/gemm_driver.cpp
+index 0773b212..df7bc44d 100644
+--- a/src/cpu/gemm/gemm_driver.cpp
++++ b/src/cpu/gemm/gemm_driver.cpp
+@@ -1304,10 +1304,8 @@ static mkldnn_status_t gemm_threading_driver(
+ (float *) arg->co);
+ }
+
+- if (data_traits<a_type>::data_type == data_type::s8) {
+- if (gemm_s8u8s32_jump_to_gemv_s8u8s32(arg)) {
+- return mkldnn_success;
+- }
++ if (gemm_s8u8s32_jump_to_gemv_s8u8s32(arg)) {
++ return mkldnn_success;
+ }
+
+ int nthr = (mkldnn_in_parallel()) ? 1 : mkldnn_get_max_threads();
+diff --git a/src/cpu/gemm/s8x8s32/jit_avx512_core_gemv_s8u8s32.cpp b/src/cpu/gemm/s8x8s32/jit_avx512_core_gemv_s8u8s32.cpp
+index 73d50e40..81646a43 100644
+--- a/src/cpu/gemm/s8x8s32/jit_avx512_core_gemv_s8u8s32.cpp
++++ b/src/cpu/gemm/s8x8s32/jit_avx512_core_gemv_s8u8s32.cpp
+@@ -29,6 +29,10 @@ namespace cpu {
+ template <typename T>
+ int gemm_s8u8s32_jump_to_gemv_s8u8s32(T *arg);
+
++template <>
++int gemm_s8u8s32_jump_to_gemv_s8u8s32(
++ gemm_info_t<float, float, float> *arg) { return 0; }
++
+ template <>
+ int gemm_s8u8s32_jump_to_gemv_s8u8s32(
+ gemm_info_t<int8_t, uint8_t, int32_t> *arg) {

View file

@ -1,11 +1,15 @@
set(BINARY_DIR "${prebuilt_ONNX_BINARY_DIR}")
set(ONNX_INCLUDE_DIR ${BINARY_DIR})
set(ONNX_SOURCE_INCLUDE_DIR "${prebuilt_ONNX_SOURCE_DIR}/onnx")
include_directories("${ONNX_SOURCE_INCLUDE_DIR}")
add_definitions(-DONNX_BUILD_SHARED_LIBS=ON)
add_definitions(-DONNX_ML=ON)
set(BINARY_DIR "${prebuilt_ONNX_BINARY_DIR}/onnx")
set(ONNX_INCLUDE_DIR ${prebuilt_ONNX_BINARY_DIR})
set(ONNX_SOURCE_INCLUDE_DIR "${prebuilt_ONNX_SOURCE_DIR}")
set(ONNX_PROTO_INCLUDE_DIR ${ONNX_INCLUDE_DIR})
include_directories("${ONNX_SOURCE_INCLUDE_DIR}")
include_directories("${ONNX_PROTO_INCLUDE_DIR}")
if (WIN32)
set(ONNX_LIBRARY ${BINARY_DIR}/onnx.lib)
set(ONNX_PROTO_LIBRARY ${BINARY_DIR}/onnx_proto.lib)
set(ONNX_LIBRARY ${BINARY_DIR}/${CMAKE_BUILD_TYPE}/onnx.lib)
set(ONNX_PROTO_LIBRARY ${BINARY_DIR}/${CMAKE_BUILD_TYPE}/onnx_proto.lib)
else()
set(ONNX_LIBRARY ${BINARY_DIR}/libonnx.a)
set(ONNX_PROTO_LIBRARY ${BINARY_DIR}/libonnx_proto.a)

View file

@ -108,18 +108,17 @@ static bool IsUnsupportedOpMode(const Node* node, const onnxruntime::GraphViewer
//TopK opset 10 is currently not supported.
//K as input is currently not suppported.
return node->InputDefs().size() > 1;
} else if (optype == "LSTM") {
const auto& attributes = node->GetAttributes();
const auto direction_attr = attributes.find("direction");
if (direction_attr != attributes.end()) {
return direction_attr->second.s() == "reverse";
}
} else if (optype == "MatMul") {
//All matmuls except float have computation missmatch
const bool A_is_float = node->InputDefs()[0]->Type()->find("float") != std::string::npos;
const bool B_is_float = node->InputDefs()[1]->Type()->find("float") != std::string::npos;
return (A_is_float && B_is_float) ? false : true;
} else if (optype == "Pad") {
// Pad is only supported only up to opset 10 (in opset 11 more inputs were added)
if (node->InputDefs().size() > 1) {
return true;
}
//3D pad with negative padding have computation missmatch
const auto& attributes = node->GetAttributes();
const auto pad_attr = attributes.find("pads");
@ -129,6 +128,14 @@ static bool IsUnsupportedOpMode(const Node* node, const onnxruntime::GraphViewer
return true;
}
}
const auto mode_attr = attributes.find("mode");
if(mode_attr != attributes.end())
{
const auto mode = mode_attr->second.s();
static const std::set<std::string> allowed_modes = {"constant", "reflect"};
return allowed_modes.count(mode) == 0;
}
} else if (optype == "Slice") {
//Slice in opset 10 is currently not supported.
//unsupported inputs: starts, ends, axes, steps
@ -157,17 +164,6 @@ static bool IsUnsupportedOpMode(const Node* node, const onnxruntime::GraphViewer
if (ceil_attr != attributes.end() && ceil_attr->second.i() != 0) {
return true;
}
} else if (optype == "Split") {
const auto& attributes = node->GetAttributes();
const auto split_attr = attributes.find("split");
if (split_attr != attributes.end()) {
// split implementation contains a bug that doesn't throw for incorrect split values
// disabling temporarily until it's fixed in the next release of nGraph
const auto splits = split_attr->second.ints();
return std::any_of(std::begin(splits), std::end(splits),
[](const auto split) { return split <= 0; });
}
} else if (optype == "QLinearMatMul") {
const auto& a_zero_point = node->InputDefs()[2];
const auto& b_zero_point = node->InputDefs()[5];
@ -284,7 +280,6 @@ static bool IsNodeSupported(const std::map<std::string, std::set<std::string>>&
}
static void AppendClusterToSubGraph(const std::vector<NodeIndex>& nodes,
const onnxruntime::GraphViewer& graph_viewer,
const std::vector<std::string>& inputs,
const std::vector<std::string>& outputs,
std::vector<std::unique_ptr<ComputeCapability>>& result) {
@ -298,13 +293,6 @@ static void AppendClusterToSubGraph(const std::vector<NodeIndex>& nodes,
meta_def->inputs = inputs;
meta_def->outputs = outputs;
//store the name of the graph this node belongs to - used to retrieve graph initializers from the cache
ONNX_NAMESPACE::AttributeProto graph_name;
graph_name.set_name("graph_name");
graph_name.set_type(ONNX_NAMESPACE::AttributeProto_AttributeType::AttributeProto_AttributeType_STRING);
graph_name.set_s(graph_viewer.Name());
meta_def->attributes["graph_name"] = graph_name;
std::unique_ptr<IndexedSubGraph> sub_graph = onnxruntime::make_unique<IndexedSubGraph>();
sub_graph->nodes = nodes;
sub_graph->SetMetaDef(meta_def);
@ -320,7 +308,7 @@ static std::map<std::string, std::set<std::string>> GetNgSupportedOps(const int
std::map<std::string, std::set<std::string>> ng_supported_ops;
ng_supported_ops.emplace(kOnnxDomain, ngraph::onnx_import::get_supported_operators(onnx_opset, kOnnxDomain));
const std::set<std::string> ng_disabled_ops = {"LSTM", "Gather"}; //Place-holder for ops not supported.
const std::set<std::string> ng_disabled_ops = {"LSTM"}; //Place-holder for ops not supported.
for (const auto& disabled_op : ng_disabled_ops) {
ng_supported_ops.at(kOnnxDomain).erase(disabled_op);
@ -517,7 +505,7 @@ NGRAPHExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
[&outputs](const NodeArg* node_arg) { outputs.push_back(node_arg->Name()); });
// Create and add this graph to result.
AppendClusterToSubGraph(graph_viewer.GetNodesInTopologicalOrder(), graph_viewer, inputs, outputs, result);
AppendClusterToSubGraph(graph_viewer.GetNodesInTopologicalOrder(), inputs, outputs, result);
} else { // unsupported_nodes_idx.empty()
const auto ng_clusters = GetPartitionedClusters(graph_viewer.GetNodesInTopologicalOrder(), unsupported_nodes);
@ -527,7 +515,7 @@ NGRAPHExecutionProvider::GetCapability(const onnxruntime::GraphViewer& graph_vie
GetInputsOutputsOfCluster(graph_viewer, this_cluster, ng_required_initializers, cluster_inputs, cluster_outputs);
if (!cluster_inputs.empty()) {
AppendClusterToSubGraph(this_cluster, graph_viewer, cluster_inputs, cluster_outputs, result);
AppendClusterToSubGraph(this_cluster, cluster_inputs, cluster_outputs, result);
}
}
}
@ -541,17 +529,14 @@ static ONNX_NAMESPACE::ModelProto GetModelProtoFromFusedNode(const onnxruntime::
ORT_ENFORCE(node_function != nullptr, "Could not extract function body for node: ", fused_node->Name());
const Graph& node_subgraph = node_function->Body();
onnxruntime::Model model{node_subgraph.Name(), true};
onnxruntime::Model model{node_subgraph.Name(), true, ModelMetaData{},
IOnnxRuntimeOpSchemaRegistryList{}, node_subgraph.DomainToVersionMap()};
ONNX_NAMESPACE::ModelProto model_proto = model.ToProto();
model_proto.set_ir_version(ONNX_NAMESPACE::Version::IR_VERSION);
*(model_proto.mutable_graph()) = node_subgraph.ToGraphProto();
auto opset = model_proto.add_opset_import();
opset->set_domain(kOnnxDomain);
opset->set_version(node_subgraph.DomainToVersionMap().at(kOnnxDomain));
return model_proto;
}

View file

@ -439,9 +439,7 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
};
#ifdef USE_NGRAPH
broken_tests.insert({"dequantizelinear", "ambiguity in scalar dimensions [] vs [1]", {"onnx150"}});
broken_tests.insert({"qlinearconv", "ambiguity in scalar dimensions [] vs [1]"});
broken_tests.insert({"quantizelinear", "ambiguity in scalar dimensions [] vs [1]", {"onnx150"}});
broken_tests.insert({"clip_splitbounds", "not implemented yet for opset 11"});
broken_tests.insert({"clip_outbounds", "not implemented yet for opset 11"});
broken_tests.insert({"clip_example", "not implemented yet for opset 11"});
@ -450,38 +448,9 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
broken_tests.insert({"clip", "not implemented yet for opset 11"});
broken_tests.insert({"depthtospace_crd_mode_example", "NGraph does not support CRD mode"});
broken_tests.insert({"depthtospace_crd_mode", "NGraph does not support CRD mode"});
broken_tests.insert({"argmax_negative_axis_keepdims_example", "not implemented yet for opset 11"});
broken_tests.insert({"argmax_negative_axis_keepdims_random", "not implemented yet for opset 11"});
broken_tests.insert({"argmin_negative_axis_keepdims_example", "not implemented yet for opset 11"});
broken_tests.insert({"argmin_negative_axis_keepdims_random", "not implemented yet for opset 11"});
broken_tests.insert({"gemm_default_no_bias", "not implemented yet for opset 11"});
broken_tests.insert({"hardmax_negative_axis", "not implemented yet for opset 11"});
broken_tests.insert({"flatten_negative_axis1", "not implemented yet for opset 11"});
broken_tests.insert({"flatten_negative_axis2", "not implemented yet for opset 11"});
broken_tests.insert({"flatten_negative_axis3", "not implemented yet for opset 11"});
broken_tests.insert({"flatten_negative_axis4", "not implemented yet for opset 11"});
broken_tests.insert({"squeeze_negative_axes", "not implemented yet for opset 11"});
broken_tests.insert({"unsqueeze_negative_axes", "not implemented yet for opset 11"});
broken_tests.insert({"reduce_sum_square_negative_axes_keepdims_random", "ReduceSumSquare(11) not implemented yet"});
broken_tests.insert({"reduce_sum_square_negative_axes_keepdims_example", "ReduceSumSquare(11) not implemented yet"});
broken_tests.insert({"reduce_sum_negative_axes_keepdims_random", "ReduceSum(11) not implemented yet"});
broken_tests.insert({"reduce_sum_negative_axes_keepdims_example", "ReduceSum(11) not implemented yet"});
broken_tests.insert({"reduce_prod_negative_axes_keepdims_random", "ReduceProd(11) not implemented yet"});
broken_tests.insert({"reduce_prod_negative_axes_keepdims_example", "ReduceProd(11) not implemented yet"});
broken_tests.insert({"reduce_min_negative_axes_keepdims_random", "ReduceMin(11) not implemented yet"});
broken_tests.insert({"reduce_min_negative_axes_keepdims_example", "ReduceMin(11) not implemented yet"});
broken_tests.insert({"reduce_mean_negative_axes_keepdims_random", "ReduceMean(11) not implemented yet"});
broken_tests.insert({"reduce_mean_negative_axes_keepdims_example", "ReduceMean(11) not implemented yet"});
broken_tests.insert({"reduce_max_negative_axes_keepdims_random", "ReduceMax(11) not implemented yet"});
broken_tests.insert({"reduce_max_negative_axes_keepdims_example", "ReduceMax(11) not implemented yet"});
broken_tests.insert({"reduce_log_sum_negative_axes", "ReduceLogSum(11) not implemented yet"});
broken_tests.insert({"reduce_log_sum_exp_negative_axes_keepdims_random", "ReduceLogSumExp(11) not implemented yet"});
broken_tests.insert({"reduce_log_sum_exp_negative_axes_keepdims_example", "ReduceLogSumExp(11) not implemented yet"});
broken_tests.insert({"reduce_l2_negative_axes_keep_dims_random", "ReduceL2(11) not implemented yet"});
broken_tests.insert({"reduce_l2_negative_axes_keep_dims_example", "ReduceL2(11) not implemented yet"});
broken_tests.insert({"reduce_l1_negative_axes_keep_dims_random", "ReduceL1(11) not implemented yet"});
broken_tests.insert({"reduce_l1_negative_axes_keep_dims_example", "ReduceL1(11) not implemented yet"});
broken_tests.insert({"constant_pad", "not implemented yet for opset 11"});
broken_tests.insert({"quantizelinear", "ambiguity in scalar dimensions [] vs [1]", {"onnx150"}});
broken_tests.insert({"dequantizelinear", "ambiguity in scalar dimensions [] vs [1]", {"onnx150"}});
#endif
#ifdef USE_MKLDNN

View file

@ -22,13 +22,7 @@ static void RunTest(const std::vector<float>& x_vals,
test.AddInput<float>("X", dimensions, x_vals);
test.AddOutput<float>("Y", dimensions, expected_vals);
std::unordered_set<std::string> excluded_eps;
if (axis < 0) {
excluded_eps.insert(kNGraphExecutionProvider); // NGraph EP cannot handle negative axis values
}
test.Run(expect_result, expected_err_str, excluded_eps);
test.Run(expect_result, expected_err_str);
}
TEST(HardmaxOperator, Simple) {

View file

@ -68,7 +68,7 @@ std::vector<ShrinkTestData<T>> GenerateUnsignedTestCases() {
}
template <typename T>
void RunShrinkTest(const std::vector<ShrinkTestData<T>>& test_cases, const std::unordered_set<std::string>& excluded_provider_types = {}) {
void RunShrinkTest(const std::vector<ShrinkTestData<T>>& test_cases) {
for (const auto& test_data : test_cases) {
OpTester test("Shrink", 9);
@ -82,7 +82,7 @@ void RunShrinkTest(const std::vector<ShrinkTestData<T>>& test_cases, const std::
test.AddInput<T>("X", test_data.input_dimensions, test_data.input_vals);
test.AddOutput<T>("Y", test_data.expected_dimensions, test_data.expected_vals);
test.Run(OpTester::ExpectResult::kExpectSuccess, {}, excluded_provider_types);
test.Run();
}
}
@ -101,7 +101,7 @@ TEST(MathOpTest, ShrinkInt8Type) {
TEST(MathOpTest, ShrinkUint8Type) {
const auto& test_cases = GenerateUnsignedTestCases<uint8_t>();
RunShrinkTest<uint8_t>(test_cases, {kNGraphExecutionProvider});
RunShrinkTest<uint8_t>(test_cases);
}
TEST(MathOpTest, ShrinkInt16Type) {
@ -111,7 +111,7 @@ TEST(MathOpTest, ShrinkInt16Type) {
TEST(MathOpTest, ShrinkUint16Type) {
const auto& test_cases = GenerateUnsignedTestCases<uint16_t>();
RunShrinkTest<uint16_t>(test_cases, {kNGraphExecutionProvider});
RunShrinkTest<uint16_t>(test_cases);
}
TEST(MathOpTest, ShrinkInt32Type) {
@ -121,7 +121,7 @@ TEST(MathOpTest, ShrinkInt32Type) {
TEST(MathOpTest, ShrinkUint32Type) {
const auto& test_cases = GenerateUnsignedTestCases<uint32_t>();
RunShrinkTest<uint32_t>(test_cases, {kNGraphExecutionProvider});
RunShrinkTest<uint32_t>(test_cases);
}
TEST(MathOpTest, ShrinkInt64Type) {
@ -131,7 +131,7 @@ TEST(MathOpTest, ShrinkInt64Type) {
TEST(MathOpTest, ShrinkUint64Type) {
const auto& test_cases = GenerateUnsignedTestCases<uint64_t>();
RunShrinkTest<uint64_t>(test_cases, {kNGraphExecutionProvider});
RunShrinkTest<uint64_t>(test_cases);
}
TEST(MathOpTest, ShrinkFloatType) {

View file

@ -22,30 +22,17 @@ void TestReduceOp(const std::string& op,
{
OpTester test(op.c_str(), opset_version);
bool has_neg_axis = false;
if (!axes.empty()) {
if (op.compare("ArgMax") == 0 || op.compare("ArgMin") == 0) {
if (op.compare("ArgMax") == 0 || op.compare("ArgMin") == 0)
test.AddAttribute("axis", axes[0]);
if (axes[0] < 0)
has_neg_axis = true;
} else {
else
test.AddAttribute("axes", axes);
for (auto& x : axes) {
has_neg_axis = (has_neg_axis || (x < 0));
}
}
}
test.AddAttribute("keepdims", keepdims);
test.AddInput<float>("data", input_dims, data);
test.AddOutput<OutT>("reduced", expected_dims, expected_data);
std::unordered_set<std::string> excluded_eps = {kCudaExecutionProvider, kTensorrtExecutionProvider}; //TensorRT: result differs
if (has_neg_axis) {
excluded_eps.insert(kNGraphExecutionProvider); // NGraph EP cannot handle negative axis values
}
test.Run(OpTester::ExpectResult::kExpectSuccess, "", excluded_eps);
test.Run(OpTester::ExpectResult::kExpectSuccess, "", {kCudaExecutionProvider, kTensorrtExecutionProvider}); //TensorRT: result differs
}
TEST(ReductionOpTest, ReductionVariationTest) {
@ -1141,8 +1128,7 @@ TEST(ReductionOpTest, ArgMax_int32_neg_axis) {
1, 1,
1, 1});
std::unordered_set<std::string> excluded_eps = {kNGraphExecutionProvider}; // NGraph EP cannot handle negative axis values
test.Run(OpTester::ExpectResult::kExpectSuccess, "", excluded_eps);
test.Run();
}
TEST(ReductionOpTest, ArgMax2D) {
@ -1242,8 +1228,7 @@ TEST(ReductionOpTest, ArgMin_int32_neg_axis) {
{0, 0,
0, 0});
std::unordered_set<std::string> excluded_eps = {kNGraphExecutionProvider}; // NGraph EP cannot handle negative axis values
test.Run(OpTester::ExpectResult::kExpectSuccess, "", excluded_eps);
test.Run();
}
} // namespace test