From fdd3c1687ff7cced237522af5aab3b590becfce2 Mon Sep 17 00:00:00 2001 From: Irina Efode Date: Tue, 15 Sep 2020 16:59:38 +0300 Subject: [PATCH] Tests (#7) * PriorBox * Mod * NormilizeL2 * Update prior_box.hpp --- ngraph/test/backend/fused_op.in.cpp | 2 +- ngraph/test/onnx/onnx_import.in.cpp | 3 +- .../runtime/interpreter/evaluates_map.cpp | 37 ++++++++++++++++ .../runtime/interpreter/opset_int_tbl.hpp | 2 + .../runtime/interpreter/reference/mod.hpp | 42 +++++++++++++++++++ 5 files changed, 84 insertions(+), 2 deletions(-) create mode 100644 ngraph/test/runtime/interpreter/reference/mod.hpp diff --git a/ngraph/test/backend/fused_op.in.cpp b/ngraph/test/backend/fused_op.in.cpp index b922cbe1ea1e10..ca8bf988925546 100644 --- a/ngraph/test/backend/fused_op.in.cpp +++ b/ngraph/test/backend/fused_op.in.cpp @@ -243,7 +243,7 @@ NGRAPH_TEST(${BACKEND_NAME}, depth_to_space_depth_first) 7.f, 23.f, 12.f, 28.f, 14.f, 30.f, 13.f, 29.f, 15.f, 31.f}); test_case.run(); } -// TODO: enable normalizeL2 tests after normalizeL2 reference implementation +// TODO: Issue: 37521 NGRAPH_TEST(${BACKEND_NAME}, DISABLED_normalize_across_chw_4d) { Shape data_shape{1, 2, 3, 4}; diff --git a/ngraph/test/onnx/onnx_import.in.cpp b/ngraph/test/onnx/onnx_import.in.cpp index 945a0d815f9945..023f499f0c7210 100644 --- a/ngraph/test/onnx/onnx_import.in.cpp +++ b/ngraph/test/onnx/onnx_import.in.cpp @@ -2528,7 +2528,8 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_prior_box) test_case.run(); } -NGRAPH_TEST(${BACKEND_NAME}, onnx_normalize) +// TODO: Issue: 37521 +NGRAPH_TEST(${BACKEND_NAME}, DISABLED_onnx_normalize) { const auto function = onnx_import::import_onnx_model( file_util::path_join(SERIALIZED_ZOO, "onnx/normalize.prototxt")); diff --git a/ngraph/test/runtime/interpreter/evaluates_map.cpp b/ngraph/test/runtime/interpreter/evaluates_map.cpp index de3ab3c8711d23..b3a84eb895f8dc 100644 --- a/ngraph/test/runtime/interpreter/evaluates_map.cpp +++ b/ngraph/test/runtime/interpreter/evaluates_map.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "ngraph/ops.hpp" #include "ngraph/runtime/reference/avg_pool.hpp" #include "ngraph/runtime/reference/batch_norm.hpp" @@ -455,6 +457,38 @@ namespace return true; } + template + bool evaluate(const shared_ptr& op, + const HostTensorVector& outputs, + const HostTensorVector& input) + { + using T = typename element_type_traits::value_type; + std::cout << "djdkldld" << std::endl; + std:: cout << input[0]->get_data_ptr()[0] << " " << input[0]->get_data_ptr()[1] << std::endl; + auto cons = dynamic_pointer_cast(op->input_value(0).get_node_shared_ptr()); + auto vec = cons->get_vector(); + runtime::reference::prior_box(input[0]->get_data_ptr(), + input[1]->get_data_ptr(), + outputs[0]->get_data_ptr(), + outputs[0]->get_shape(), + op->get_attrs()); + return true; + } + + template + bool evaluate(const shared_ptr& op, + const HostTensorVector& outputs, + const HostTensorVector& input) + { + using T = typename element_type_traits::value_type; + runtime::reference::mod(input[0]->get_data_ptr(), + input[1]->get_data_ptr(), + outputs[0]->get_data_ptr(), + input[0]->get_shape(), + op->get_auto_broadcast()); + return true; + } + template bool evaluate(const shared_ptr& op, const HostTensorVector& outputs, @@ -779,6 +813,9 @@ namespace throw std::logic_error("Output node element types is not equal"); } } + if (is_type(node)) { + element_type = node->get_input_element_type(0); + } switch (element_type) { case element::Type_t::boolean: diff --git a/ngraph/test/runtime/interpreter/opset_int_tbl.hpp b/ngraph/test/runtime/interpreter/opset_int_tbl.hpp index 9c2732d91e2390..885ca53298bc61 100644 --- a/ngraph/test/runtime/interpreter/opset_int_tbl.hpp +++ b/ngraph/test/runtime/interpreter/opset_int_tbl.hpp @@ -29,6 +29,7 @@ NGRAPH_OP(Gelu, op::v0) NGRAPH_OP(HardSigmoid, op::v0) NGRAPH_OP(LRN, ngraph::op::v0) NGRAPH_OP(MVN, ngraph::op::v0) +NGRAPH_OP(PriorBox, ngraph::op::v0) NGRAPH_OP(ReverseSequence, op::v0) NGRAPH_OP(RNNCell, op::v0) NGRAPH_OP(Selu, op::v0) @@ -44,6 +45,7 @@ NGRAPH_OP(LogicalOr, op::v1) NGRAPH_OP(LogicalXor, op::v1) NGRAPH_OP(LogicalNot, op::v1) NGRAPH_OP(MaxPool, op::v1) +NGRAPH_OP(Mod, op::v1) NGRAPH_OP(OneHot, op::v1) NGRAPH_OP(Pad, op::v1) NGRAPH_OP(Select, op::v1) diff --git a/ngraph/test/runtime/interpreter/reference/mod.hpp b/ngraph/test/runtime/interpreter/reference/mod.hpp new file mode 100644 index 00000000000000..72289c50179240 --- /dev/null +++ b/ngraph/test/runtime/interpreter/reference/mod.hpp @@ -0,0 +1,42 @@ +//***************************************************************************** +// Copyright 2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +//***************************************************************************** + +#pragma once + +#include +#include + +namespace ngraph +{ + namespace runtime + { + namespace reference + { + template + void mod(const T* arg0, + const T* arg1, + T* out, + const Shape& arg_shape, + const op::AutoBroadcastSpec& broadcast_spec) + { + autobroadcast_binop( + arg0, arg1, out, arg_shape, arg_shape, broadcast_spec, [](T x, T y) -> T { + return T(x - std::trunc(x / y) * y); + }); + } + } + } +}