Remove atan2 (#1184)

This commit is contained in:
Ilya Churaev 2020-07-06 06:18:45 +03:00 committed by GitHub
parent fd9ae15fdd
commit 84f7cd2c02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 12 additions and 138 deletions

View 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

View 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)

View 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"

View 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},

View 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:

View 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

View File

@ -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)));
}

View 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}");

View 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};

View 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());

View 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
)

View 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

View 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"

View 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)

View 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;
}
}

View File

@ -17,6 +17,7 @@
#pragma once
#include "ngraph/ops.hpp"
#include "op/atan2.hpp"
#include "op/avg_pool.hpp"
namespace ngraph

View 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)

View 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;