Remove atan2 (#1184)
authorIlya Churaev <ilya.churaev@intel.com>
Mon, 6 Jul 2020 03:18:45 +0000 (06:18 +0300)
committerGitHub <noreply@github.com>
Mon, 6 Jul 2020 03:18:45 +0000 (06:18 +0300)
18 files changed:
ngraph/src/ngraph/CMakeLists.txt
ngraph/src/ngraph/op/op_version_tbl.hpp
ngraph/src/ngraph/ops.hpp
ngraph/src/ngraph/pass/cse.cpp
ngraph/src/ngraph/serializer.cpp
ngraph/test/CMakeLists.txt
ngraph/test/backend/atan2.in.cpp [deleted file]
ngraph/test/backend/autodiff.in.cpp
ngraph/test/copy.cpp
ngraph/test/op_is.cpp
ngraph/test/runtime/CMakeLists.txt
ngraph/test/runtime/ie/unit_test.manifest
ngraph/test/runtime/interpreter/int_executable.cpp
ngraph/test/runtime/op/atan2.cpp [moved from ngraph/src/ngraph/op/atan2.cpp with 96% similarity]
ngraph/test/runtime/op/atan2.hpp [moved from ngraph/src/ngraph/op/atan2.hpp with 94% similarity]
ngraph/test/runtime/opset0.hpp
ngraph/test/runtime/opset0_tbl.hpp
ngraph/test/runtime/opset1_upgrade.cpp

index 723e7e4..c11a6f8 100644 (file)
@@ -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
index 0838c5c..0a95bf6 100644 (file)
@@ -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)
index fbe0f29..3c107da 100644 (file)
@@ -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"
index 56550f8..d25f403 100644 (file)
@@ -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<type_index, function<bool(shared_ptr<Node>, shared_ptr<Node
          {TI(op::Acos), cse_unarywise},
          {TI(op::Asin), cse_unarywise},
          {TI(op::Atan), cse_unarywise},
-         {TI(op::Atan2), cse_binarywise},
          {TI(op::Ceiling), cse_unarywise},
          {TI(op::Constant), cse_constant},
          {TI(op::Cos), cse_unarywise},
index 4047959..f60b0fb 100644 (file)
@@ -1005,11 +1005,6 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json node_js)
             node = make_shared<op::Atan>(args[0]);
             break;
         }
-        case OP_TYPEID::Atan2:
-        {
-            node = make_shared<op::Atan2>(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<const op::Atan2*>(&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:
index f4c377c..f67f8bf 100644 (file)
@@ -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 (file)
index d76914a..0000000
+++ /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 <algorithm>
-#include <cinttypes>
-#include <cmath>
-#include <cstdlib>
-#include <random>
-#include <string>
-
-// 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<op::Parameter>(element::f32, shape);
-    auto Y = make_shared<op::Parameter>(element::f32, shape);
-    auto f = make_shared<Function>(make_shared<op::Atan2>(Y, X), ParameterVector{X, Y});
-
-    auto backend = runtime::Backend::create("${BACKEND_NAME}");
-
-    // Create some tensors for input/output
-    shared_ptr<runtime::Tensor> x = backend->create_tensor(element::f32, shape);
-    shared_ptr<runtime::Tensor> y = backend->create_tensor(element::f32, shape);
-    shared_ptr<runtime::Tensor> result = backend->create_tensor(element::f32, shape);
-
-    std::vector<float> xref;
-    std::vector<float> yref;
-    std::vector<float> 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<float>((i + 1) * std::cos(theta)));
-        yref.push_back(static_cast<float>((i + 1) * std::sin(theta)));
-        zref.push_back(-theta);
-        xref.push_back(static_cast<float>((i + 1) * std::cos(-theta)));
-        yref.push_back(static_cast<float>((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<float>(result), (zref)));
-}
index 02a1000..c4ef970 100644 (file)
@@ -152,23 +152,6 @@ NGRAPH_TEST(${BACKEND_NAME}, backwards_atan)
     EXPECT_TRUE(autodiff_numeric_compare<float>(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<float> rng(-5.0f, 5.0f);
-    auto y = rng.initialize(backend->create_tensor<float>(shape));
-    auto x = rng.initialize(backend->create_tensor<float>(shape));
-
-    auto make_graph = [shape]() {
-        auto X = make_shared<op::Parameter>(element::f32, shape);
-        auto Y = make_shared<op::Parameter>(element::f32, shape);
-        return make_shared<Function>(make_shared<op::Atan2>(Y, X), ParameterVector{Y, X});
-    };
-    EXPECT_TRUE(autodiff_numeric_compare<float>(backend.get(), make_graph, {y, x}, .01f, .01f));
-}
-
 NGRAPH_TEST(${BACKEND_NAME}, backwards_broadcast0)
 {
     auto backend = runtime::Backend::create("${BACKEND_NAME}");
index c627553..04fd719 100644 (file)
@@ -79,11 +79,6 @@ TEST(copy, atan)
     ASSERT_TRUE(check_unary<op::Atan>());
 }
 
-TEST(copy, atan2)
-{
-    ASSERT_TRUE(check_binary<op::Atan2>());
-}
-
 TEST(copy, broadcast)
 {
     Shape shape1{1};
index 57ad603..4f69978 100644 (file)
@@ -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());
index 71e45a1..8e48236 100644 (file)
@@ -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
     )
index 68bbdb6..b8206de 100644 (file)
@@ -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
index 47ff9ee..422f3fb 100644 (file)
@@ -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"
 
similarity index 96%
rename from ngraph/src/ngraph/op/atan2.cpp
rename to ngraph/test/runtime/op/atan2.cpp
index a2900e7..2f54c4a 100644 (file)
@@ -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<Node>& y, const Output<Node>& x, const AutoBroadcastSpec& autob)
     : BinaryElementwiseArithmetic(y, x, autob)
similarity index 94%
rename from ngraph/src/ngraph/op/atan2.hpp
rename to ngraph/test/runtime/op/atan2.hpp
index 067e92b..bf500b6 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <memory>
 
+#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;
     }
 }
index e46665b..60f2dae 100644 (file)
@@ -17,6 +17,7 @@
 #pragma once
 
 #include "ngraph/ops.hpp"
+#include "op/atan2.hpp"
 #include "op/avg_pool.hpp"
 
 namespace ngraph
index bf7c71a..efbead3 100644 (file)
@@ -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)
index 2bd0dcd..42c9e4e 100644 (file)
@@ -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;