From 84f7cd2c02546a343a7e16965c8889ba4e43c489 Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Mon, 6 Jul 2020 06:18:45 +0300 Subject: [PATCH] Remove atan2 (#1184) --- ngraph/src/ngraph/CMakeLists.txt | 2 - ngraph/src/ngraph/op/op_version_tbl.hpp | 1 - ngraph/src/ngraph/ops.hpp | 1 - ngraph/src/ngraph/pass/cse.cpp | 2 - ngraph/src/ngraph/serializer.cpp | 14 ---- ngraph/test/CMakeLists.txt | 1 - ngraph/test/backend/atan2.in.cpp | 85 ---------------------- ngraph/test/backend/autodiff.in.cpp | 17 ----- ngraph/test/copy.cpp | 5 -- ngraph/test/op_is.cpp | 3 +- ngraph/test/runtime/CMakeLists.txt | 2 + ngraph/test/runtime/ie/unit_test.manifest | 4 - ngraph/test/runtime/interpreter/int_executable.cpp | 1 + ngraph/{src/ngraph => test/runtime}/op/atan2.cpp | 4 +- ngraph/{src/ngraph => test/runtime}/op/atan2.hpp | 4 +- ngraph/test/runtime/opset0.hpp | 1 + ngraph/test/runtime/opset0_tbl.hpp | 2 +- ngraph/test/runtime/opset1_upgrade.cpp | 1 + 18 files changed, 12 insertions(+), 138 deletions(-) delete mode 100644 ngraph/test/backend/atan2.in.cpp rename ngraph/{src/ngraph => test/runtime}/op/atan2.cpp (96%) rename ngraph/{src/ngraph => test/runtime}/op/atan2.hpp (94%) diff --git a/ngraph/src/ngraph/CMakeLists.txt b/ngraph/src/ngraph/CMakeLists.txt index 723e7e4..c11a6f8 100644 --- a/ngraph/src/ngraph/CMakeLists.txt +++ b/ngraph/src/ngraph/CMakeLists.txt @@ -143,8 +143,6 @@ set (SRC op/atan.hpp op/atanh.cpp op/atanh.hpp - op/atan2.cpp - op/atan2.hpp op/avg_pool.cpp op/avg_pool.hpp op/batch_norm.cpp diff --git a/ngraph/src/ngraph/op/op_version_tbl.hpp b/ngraph/src/ngraph/op/op_version_tbl.hpp index 0838c5c..0a95bf6 100644 --- a/ngraph/src/ngraph/op/op_version_tbl.hpp +++ b/ngraph/src/ngraph/op/op_version_tbl.hpp @@ -41,7 +41,6 @@ NGRAPH_OP(Asin, ngraph::op::v0, 0) NGRAPH_OP(Asinh, ngraph::op::v3, 3) NGRAPH_OP(Atan, ngraph::op::v0, 0) NGRAPH_OP(Atanh, ngraph::op::v3, 3) -NGRAPH_OP(Atan2, ngraph::op::v0, 0) NGRAPH_OP(AvgPool, ngraph::op::v1, 1) NGRAPH_OP(BatchMatMul, ngraph::op::v0, 0) NGRAPH_OP(BatchMatMulTranspose, ngraph::op::v0, 0) diff --git a/ngraph/src/ngraph/ops.hpp b/ngraph/src/ngraph/ops.hpp index fbe0f29..3c107da 100644 --- a/ngraph/src/ngraph/ops.hpp +++ b/ngraph/src/ngraph/ops.hpp @@ -32,7 +32,6 @@ #include "ngraph/op/asinh.hpp" #include "ngraph/op/assign.hpp" #include "ngraph/op/atan.hpp" -#include "ngraph/op/atan2.hpp" #include "ngraph/op/atanh.hpp" #include "ngraph/op/avg_pool.hpp" #include "ngraph/op/batch_norm.hpp" diff --git a/ngraph/src/ngraph/pass/cse.cpp b/ngraph/src/ngraph/pass/cse.cpp index 56550f8..d25f403 100644 --- a/ngraph/src/ngraph/pass/cse.cpp +++ b/ngraph/src/ngraph/pass/cse.cpp @@ -29,7 +29,6 @@ #include "ngraph/op/add.hpp" #include "ngraph/op/asin.hpp" #include "ngraph/op/atan.hpp" -#include "ngraph/op/atan2.hpp" #include "ngraph/op/broadcast.hpp" #include "ngraph/op/ceiling.hpp" #include "ngraph/op/constant.hpp" @@ -176,7 +175,6 @@ static unordered_map, shared_ptr JSONDeserializer::deserialize_node(json node_js) node = make_shared(args[0]); break; } - case OP_TYPEID::Atan2: - { - node = make_shared(args[0], args[1], read_auto_broadcast(node_js, "autob")); - break; - } case OP_TYPEID::BatchMatMul: { @@ -2553,15 +2548,6 @@ json JSONSerializer::serialize_node(const Node& n) } case OP_TYPEID::Atan: { break; } - case OP_TYPEID::Atan2: - { - auto tmp = dynamic_cast(&n); - if (tmp->get_autob().m_type != op::AutoBroadcastType::NONE) - { - node["autob"] = write_auto_broadcast(tmp->get_autob()); - } - break; - } case OP_TYPEID::BatchMatMul: { break; } case OP_TYPEID::BatchMatMulTranspose: diff --git a/ngraph/test/CMakeLists.txt b/ngraph/test/CMakeLists.txt index f4c377c..f67f8bf 100644 --- a/ngraph/test/CMakeLists.txt +++ b/ngraph/test/CMakeLists.txt @@ -298,7 +298,6 @@ set(MULTI_TEST_SRC backend/asin.in.cpp backend/asinh.in.cpp backend/atan.in.cpp - backend/atan2.in.cpp backend/atanh.in.cpp backend/auto_broadcast.in.cpp backend/autodiff.in.cpp diff --git a/ngraph/test/backend/atan2.in.cpp b/ngraph/test/backend/atan2.in.cpp deleted file mode 100644 index d76914a..0000000 --- a/ngraph/test/backend/atan2.in.cpp +++ /dev/null @@ -1,85 +0,0 @@ -//***************************************************************************** -// Copyright 2017-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. -//***************************************************************************** - -#include -#include -#include -#include -#include -#include - -// clang-format off -#ifdef ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#define DEFAULT_FLOAT_TOLERANCE_BITS ${BACKEND_NAME}_FLOAT_TOLERANCE_BITS -#endif - -#ifdef ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#define DEFAULT_DOUBLE_TOLERANCE_BITS ${BACKEND_NAME}_DOUBLE_TOLERANCE_BITS -#endif -// clang-format on - -#include "gtest/gtest.h" -#include "ngraph/ngraph.hpp" -#include "runtime/backend.hpp" -#include "ngraph/runtime/tensor.hpp" -#include "util/all_close.hpp" -#include "util/all_close_f.hpp" -#include "util/ndarray.hpp" -#include "util/test_control.hpp" -#include "util/test_tools.hpp" - -using namespace std; -using namespace ngraph; - -static string s_manifest = "${MANIFEST}"; - -NGRAPH_TEST(${BACKEND_NAME}, atan2) -{ - Shape shape{30}; - auto X = make_shared(element::f32, shape); - auto Y = make_shared(element::f32, shape); - auto f = make_shared(make_shared(Y, X), ParameterVector{X, Y}); - - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - - // Create some tensors for input/output - shared_ptr x = backend->create_tensor(element::f32, shape); - shared_ptr y = backend->create_tensor(element::f32, shape); - shared_ptr result = backend->create_tensor(element::f32, shape); - - std::vector xref; - std::vector yref; - std::vector zref; - int halfelts = shape.at(0) / 2; - float scale = 1.0 / (halfelts * 4.0 * std::atan(1.0)); - for (int i = 0; i < halfelts; ++i) - { - float theta = i * scale; - zref.push_back(theta); - xref.push_back(static_cast((i + 1) * std::cos(theta))); - yref.push_back(static_cast((i + 1) * std::sin(theta))); - zref.push_back(-theta); - xref.push_back(static_cast((i + 1) * std::cos(-theta))); - yref.push_back(static_cast((i + 1) * std::sin(-theta))); - } - - copy_data(x, xref); - copy_data(y, yref); - - auto handle = backend->compile(f); - handle->call_with_validate({result}, {x, y}); - EXPECT_TRUE(test::all_close_f(read_vector(result), (zref))); -} diff --git a/ngraph/test/backend/autodiff.in.cpp b/ngraph/test/backend/autodiff.in.cpp index 02a1000..c4ef970 100644 --- a/ngraph/test/backend/autodiff.in.cpp +++ b/ngraph/test/backend/autodiff.in.cpp @@ -152,23 +152,6 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_atan) EXPECT_TRUE(autodiff_numeric_compare(backend.get(), make_graph, {x0}, .01f, .01f)); } -NGRAPH_TEST(${BACKEND_NAME}, backwards_atan2) -{ - auto backend = runtime::Backend::create("${BACKEND_NAME}"); - Shape shape{30}; - - test::Uniform rng(-5.0f, 5.0f); - auto y = rng.initialize(backend->create_tensor(shape)); - auto x = rng.initialize(backend->create_tensor(shape)); - - auto make_graph = [shape]() { - auto X = make_shared(element::f32, shape); - auto Y = make_shared(element::f32, shape); - return make_shared(make_shared(Y, X), ParameterVector{Y, X}); - }; - EXPECT_TRUE(autodiff_numeric_compare(backend.get(), make_graph, {y, x}, .01f, .01f)); -} - NGRAPH_TEST(${BACKEND_NAME}, backwards_broadcast0) { auto backend = runtime::Backend::create("${BACKEND_NAME}"); diff --git a/ngraph/test/copy.cpp b/ngraph/test/copy.cpp index c627553..04fd719 100644 --- a/ngraph/test/copy.cpp +++ b/ngraph/test/copy.cpp @@ -79,11 +79,6 @@ TEST(copy, atan) ASSERT_TRUE(check_unary()); } -TEST(copy, atan2) -{ - ASSERT_TRUE(check_binary()); -} - TEST(copy, broadcast) { Shape shape1{1}; diff --git a/ngraph/test/op_is.cpp b/ngraph/test/op_is.cpp index 57ad603..4f69978 100644 --- a/ngraph/test/op_is.cpp +++ b/ngraph/test/op_is.cpp @@ -18,6 +18,7 @@ #include "ngraph/ngraph.hpp" #include "ngraph/validation_util.hpp" +#include "op/atan2.hpp" #include "util/test_tools.hpp" using namespace ngraph; @@ -125,7 +126,7 @@ namespace void op_is_Atan2() { - op::Atan2 node; + op::v0::Atan2 node; EXPECT_FALSE(node.is_unary_elementwise_arithmetic()); EXPECT_TRUE(node.is_binary_elementwise_arithmetic()); EXPECT_FALSE(node.is_binary_elementwise_comparison()); diff --git a/ngraph/test/runtime/CMakeLists.txt b/ngraph/test/runtime/CMakeLists.txt index 71e45a1..8e48236 100644 --- a/ngraph/test/runtime/CMakeLists.txt +++ b/ngraph/test/runtime/CMakeLists.txt @@ -31,6 +31,8 @@ set (SRC performance_counter.hpp dynamic/dynamic_backend.cpp dynamic/dynamic_backend.hpp + op/atan2.cpp + op/atan2.hpp op/avg_pool.cpp op/avg_pool.hpp ) diff --git a/ngraph/test/runtime/ie/unit_test.manifest b/ngraph/test/runtime/ie/unit_test.manifest index 68bbdb6..b8206de 100644 --- a/ngraph/test/runtime/ie/unit_test.manifest +++ b/ngraph/test/runtime/ie/unit_test.manifest @@ -1032,9 +1032,6 @@ batch_mat_mul_forward # Incorrect dimensions for broadcasting for Add auto_bcast_binary_elementwise_pdpd_dynamic -# Unsupported primitive of type: Atan2 -atan2 - # Unsupported primitive of type: ArgMin argmin_trivial argmin_2D_i32 @@ -1161,7 +1158,6 @@ backwards_add backwards_add_nested backwards_asin backwards_atan -backwards_atan2 backwards_broadcast0 backwards_broadcast1 backwards_concat_vector diff --git a/ngraph/test/runtime/interpreter/int_executable.cpp b/ngraph/test/runtime/interpreter/int_executable.cpp index 47ff9ee..422f3fb 100644 --- a/ngraph/test/runtime/interpreter/int_executable.cpp +++ b/ngraph/test/runtime/interpreter/int_executable.cpp @@ -29,6 +29,7 @@ #include "ngraph/pass/manager.hpp" #include "ngraph/serializer.hpp" #include "ngraph/util.hpp" +#include "op/atan2.hpp" #include "opset0_downgrade.hpp" #include "opset1_downgrade.hpp" diff --git a/ngraph/src/ngraph/op/atan2.cpp b/ngraph/test/runtime/op/atan2.cpp similarity index 96% rename from ngraph/src/ngraph/op/atan2.cpp rename to ngraph/test/runtime/op/atan2.cpp index a2900e7..2f54c4a 100644 --- a/ngraph/src/ngraph/op/atan2.cpp +++ b/ngraph/test/runtime/op/atan2.cpp @@ -14,7 +14,7 @@ // limitations under the License. //***************************************************************************** -#include "ngraph/op/atan2.hpp" +#include "atan2.hpp" #include "ngraph/op/add.hpp" #include "ngraph/op/divide.hpp" #include "ngraph/op/multiply.hpp" @@ -25,7 +25,7 @@ using namespace std; using namespace ngraph; -constexpr NodeTypeInfo op::Atan2::type_info; +constexpr NodeTypeInfo op::v0::Atan2::type_info; op::v0::Atan2::Atan2(const Output& y, const Output& x, const AutoBroadcastSpec& autob) : BinaryElementwiseArithmetic(y, x, autob) diff --git a/ngraph/src/ngraph/op/atan2.hpp b/ngraph/test/runtime/op/atan2.hpp similarity index 94% rename from ngraph/src/ngraph/op/atan2.hpp rename to ngraph/test/runtime/op/atan2.hpp index 067e92b..bf500b6 100644 --- a/ngraph/src/ngraph/op/atan2.hpp +++ b/ngraph/test/runtime/op/atan2.hpp @@ -18,6 +18,7 @@ #include +#include "backend_visibility.hpp" #include "ngraph/op/util/binary_elementwise_arithmetic.hpp" namespace ngraph @@ -27,7 +28,7 @@ namespace ngraph namespace v0 { /// \brief Elementwise full arctan operation - class NGRAPH_API Atan2 : public util::BinaryElementwiseArithmetic + class BACKEND_API Atan2 : public util::BinaryElementwiseArithmetic { public: static constexpr NodeTypeInfo type_info{"Atan2", 0}; @@ -54,6 +55,5 @@ namespace ngraph const OutputVector& deltas) override; }; } - using v0::Atan2; } } diff --git a/ngraph/test/runtime/opset0.hpp b/ngraph/test/runtime/opset0.hpp index e46665b..60f2dae 100644 --- a/ngraph/test/runtime/opset0.hpp +++ b/ngraph/test/runtime/opset0.hpp @@ -17,6 +17,7 @@ #pragma once #include "ngraph/ops.hpp" +#include "op/atan2.hpp" #include "op/avg_pool.hpp" namespace ngraph diff --git a/ngraph/test/runtime/opset0_tbl.hpp b/ngraph/test/runtime/opset0_tbl.hpp index bf7c71a..efbead3 100644 --- a/ngraph/test/runtime/opset0_tbl.hpp +++ b/ngraph/test/runtime/opset0_tbl.hpp @@ -61,7 +61,7 @@ NGRAPH_OP(ArgMax, ngraph::op) NGRAPH_OP(ArgMin, ngraph::op) NGRAPH_OP(Asin, ngraph::op) NGRAPH_OP(Atan, ngraph::op) -NGRAPH_OP(Atan2, ngraph::op) +NGRAPH_OP(Atan2, ngraph::op::v0) NGRAPH_OP(AvgPool, ngraph::op::v0) NGRAPH_OP(BatchMatMul, ngraph::op) NGRAPH_OP(BatchMatMulTranspose, ngraph::op) diff --git a/ngraph/test/runtime/opset1_upgrade.cpp b/ngraph/test/runtime/opset1_upgrade.cpp index 2bd0dcd..42c9e4e 100644 --- a/ngraph/test/runtime/opset1_upgrade.cpp +++ b/ngraph/test/runtime/opset1_upgrade.cpp @@ -25,6 +25,7 @@ #include "ngraph/graph_util.hpp" #include "ngraph/ops.hpp" #include "ngraph/provenance.hpp" +#include "op/atan2.hpp" #include "op/avg_pool.hpp" using namespace std; -- 2.7.4