From 3bbdda6b48e561cef061f9f26768ec710564ecba Mon Sep 17 00:00:00 2001 From: Ilya Churaev Date: Mon, 27 Jul 2020 10:49:56 +0300 Subject: [PATCH] Removed BroadcastDistributed (#1430) --- ngraph/src/ngraph/CMakeLists.txt | 1 - .../src/ngraph/op/broadcast_distributed.cpp | 65 ------------------- .../src/ngraph/op/broadcast_distributed.hpp | 50 -------------- ngraph/src/ngraph/op/op_version_tbl.hpp | 1 - ngraph/src/ngraph/ops.hpp | 1 - .../reference/broadcast_distributed.hpp | 39 ----------- ngraph/src/ngraph/serializer.cpp | 7 -- ngraph/test/op_is.cpp | 9 --- .../runtime/interpreter/int_executable.hpp | 28 -------- ngraph/test/runtime/opset0_tbl.hpp | 1 - 10 files changed, 202 deletions(-) delete mode 100644 ngraph/src/ngraph/op/broadcast_distributed.cpp delete mode 100644 ngraph/src/ngraph/op/broadcast_distributed.hpp delete mode 100644 ngraph/src/ngraph/runtime/reference/broadcast_distributed.hpp diff --git a/ngraph/src/ngraph/CMakeLists.txt b/ngraph/src/ngraph/CMakeLists.txt index e5717fd0c76..351d88d9ffe 100644 --- a/ngraph/src/ngraph/CMakeLists.txt +++ b/ngraph/src/ngraph/CMakeLists.txt @@ -136,7 +136,6 @@ set (SRC op/binary_convolution.cpp op/binary_convolution.hpp op/broadcast.cpp - op/broadcast_distributed.cpp op/bucketize.cpp op/bucketize.hpp op/ceiling.cpp diff --git a/ngraph/src/ngraph/op/broadcast_distributed.cpp b/ngraph/src/ngraph/op/broadcast_distributed.cpp deleted file mode 100644 index 7d4b4d2b239..00000000000 --- a/ngraph/src/ngraph/op/broadcast_distributed.cpp +++ /dev/null @@ -1,65 +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 "ngraph/op/broadcast_distributed.hpp" -#include "ngraph/attribute_visitor.hpp" - -using namespace std; -using namespace ngraph; - -constexpr NodeTypeInfo op::BroadcastDistributed::type_info; - -op::BroadcastDistributed::BroadcastDistributed(const Output& arg, int64_t root_id) - : Op({arg}) - , m_root_id(root_id) -{ - constructor_validate_and_infer_types(); -} - -bool op::BroadcastDistributed::visit_attributes(AttributeVisitor& visitor) -{ - visitor.on_attribute("root_id", m_root_id); - return true; -} - -void op::BroadcastDistributed::validate_and_infer_types() -{ - NODE_VALIDATION_CHECK(this, - get_input_element_type(0).is_dynamic() || - get_input_element_type(0) == element::f32 || - get_input_element_type(0) == element::f64, - "Only element types f32 and f64 are supported (argument element type: ", - get_input_element_type(0), - ")."); - - set_output_type(0, get_input_element_type(0), get_input_partial_shape(0)); -} - -shared_ptr op::BroadcastDistributed::clone_with_new_inputs(const OutputVector& new_args) const -{ - check_new_args_count(this, new_args); - return make_shared(new_args.at(0), m_root_id); -} - -int64_t op::BroadcastDistributed::get_root_id() const -{ - return m_root_id; -} - -void op::BroadcastDistributed::set_root_id(int64_t root_id) -{ - m_root_id = root_id; -} diff --git a/ngraph/src/ngraph/op/broadcast_distributed.hpp b/ngraph/src/ngraph/op/broadcast_distributed.hpp deleted file mode 100644 index 1601d65da65..00000000000 --- a/ngraph/src/ngraph/op/broadcast_distributed.hpp +++ /dev/null @@ -1,50 +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. -//***************************************************************************** - -#pragma once - -#include - -#include "ngraph/op/op.hpp" - -namespace ngraph -{ - namespace op - { - namespace v0 - { - class NGRAPH_API BroadcastDistributed : public Op - { - public: - static constexpr NodeTypeInfo type_info{"BroadcastDistributed", 0}; - const NodeTypeInfo& get_type_info() const override { return type_info; } - BroadcastDistributed() = default; - BroadcastDistributed(const Output& arg, int64_t root_id = 0); - bool visit_attributes(AttributeVisitor& visitor) override; - void validate_and_infer_types() override; - - std::shared_ptr - clone_with_new_inputs(const OutputVector& new_args) const override; - int64_t get_root_id() const; - void set_root_id(int64_t root_id); - - private: - int64_t m_root_id; - }; - } - using v0::BroadcastDistributed; - } -} diff --git a/ngraph/src/ngraph/op/op_version_tbl.hpp b/ngraph/src/ngraph/op/op_version_tbl.hpp index fb1c6e6967f..12fe09a3d09 100644 --- a/ngraph/src/ngraph/op/op_version_tbl.hpp +++ b/ngraph/src/ngraph/op/op_version_tbl.hpp @@ -43,7 +43,6 @@ NGRAPH_OP(BinaryConvolution, ngraph::op::v1, 1) NGRAPH_OP(Broadcast, ngraph::op::v0, 0) NGRAPH_OP(Broadcast, ngraph::op::v1, 1) NGRAPH_OP(Broadcast, ngraph::op::v3, 3) -NGRAPH_OP(BroadcastDistributed, ngraph::op::v0, 0) NGRAPH_OP(BroadcastLike, ngraph::op::v0, 0) NGRAPH_OP(Bucketize, ngraph::op::v3, 3) NGRAPH_OP(CTCGreedyDecoder, ngraph::op::v0, 0) diff --git a/ngraph/src/ngraph/ops.hpp b/ngraph/src/ngraph/ops.hpp index 2b09fdea803..312184f1859 100644 --- a/ngraph/src/ngraph/ops.hpp +++ b/ngraph/src/ngraph/ops.hpp @@ -33,7 +33,6 @@ #include "ngraph/op/batch_norm.hpp" #include "ngraph/op/binary_convolution.hpp" #include "ngraph/op/broadcast.hpp" -#include "ngraph/op/broadcast_distributed.hpp" #include "ngraph/op/bucketize.hpp" #include "ngraph/op/ceiling.hpp" #include "ngraph/op/concat.hpp" diff --git a/ngraph/src/ngraph/runtime/reference/broadcast_distributed.hpp b/ngraph/src/ngraph/runtime/reference/broadcast_distributed.hpp deleted file mode 100644 index 579a7019994..00000000000 --- a/ngraph/src/ngraph/runtime/reference/broadcast_distributed.hpp +++ /dev/null @@ -1,39 +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. -//***************************************************************************** - -#pragma once - -#pragma once - -#include "ngraph/distributed.hpp" - -namespace ngraph -{ - namespace runtime - { - namespace reference - { - template - void broadcastdistributed(T* arg, - const element::Type_t element_type, - int count, - int root_id) - { - get_distributed_interface()->broadcast(arg, element_type, count, root_id); - } - } - } -} diff --git a/ngraph/src/ngraph/serializer.cpp b/ngraph/src/ngraph/serializer.cpp index 0ac948dbd2b..4fe9b3bfc2b 100644 --- a/ngraph/src/ngraph/serializer.cpp +++ b/ngraph/src/ngraph/serializer.cpp @@ -990,11 +990,6 @@ shared_ptr JSONDeserializer::deserialize_node(json node_js) node = make_shared(args[0], shape, axes); break; } - case OP_TYPEID::BroadcastDistributed: - { - node = make_shared(args[0]); - break; - } case OP_TYPEID::BroadcastLike: { auto initial_axes = deserialize_axis_set(node_js.at("initial_axes")); @@ -2239,8 +2234,6 @@ json JSONSerializer::serialize_node(const Node& n) node["shape"] = tmp->get_broadcast_shape(); break; } - case OP_TYPEID::BroadcastDistributed: { break; - } case OP_TYPEID::BroadcastLike: { auto tmp = static_cast(&n); diff --git a/ngraph/test/op_is.cpp b/ngraph/test/op_is.cpp index e3b42c05b86..db754b14f3b 100644 --- a/ngraph/test/op_is.cpp +++ b/ngraph/test/op_is.cpp @@ -106,15 +106,6 @@ namespace EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); } - void op_is_BroadcastDistributed() - { - op::BroadcastDistributed node; - EXPECT_FALSE(op::is_unary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_arithmetic(&node)); - EXPECT_FALSE(op::is_binary_elementwise_comparison(&node)); - EXPECT_FALSE(op::is_binary_elementwise_logical(&node)); - } - void op_is_BroadcastLike() { op::BroadcastLike node; diff --git a/ngraph/test/runtime/interpreter/int_executable.hpp b/ngraph/test/runtime/interpreter/int_executable.hpp index f9472b32bc3..edc0fc4ae2c 100644 --- a/ngraph/test/runtime/interpreter/int_executable.hpp +++ b/ngraph/test/runtime/interpreter/int_executable.hpp @@ -37,7 +37,6 @@ #include "ngraph/runtime/reference/avg_pool.hpp" #include "ngraph/runtime/reference/batch_norm.hpp" #include "ngraph/runtime/reference/broadcast.hpp" -#include "ngraph/runtime/reference/broadcast_distributed.hpp" #include "ngraph/runtime/reference/ceiling.hpp" #include "ngraph/runtime/reference/concat.hpp" #include "ngraph/runtime/reference/constant.hpp" @@ -274,33 +273,6 @@ protected: node.get_input_shape(2)); break; } - case OP_TYPEID::BroadcastDistributed: - { - const ngraph::op::BroadcastDistributed* broadcast = - static_cast(&node); - int rank_ID; - rank_ID = get_distributed_interface()->get_rank(); - int root_id = broadcast->get_root_id(); - if (rank_ID == root_id) - { - reference::broadcastdistributed( - args[0]->get_data_ptr(), - node.get_input_element_type(0), - static_cast(shape_size(node.get_input_shape(0))), - root_id); - auto memSize = static_cast(shape_size(node.get_input_shape(0))) * sizeof(T); - memcpy(out[0]->get_data_ptr(), args[0]->get_data_ptr(), memSize); - } - else - { - reference::broadcastdistributed( - out[0]->get_data_ptr(), - node.get_input_element_type(0), - static_cast(shape_size(node.get_input_shape(0))), - root_id); - } - break; - } case OP_TYPEID::BroadcastLike: break; case OP_TYPEID::Ceiling: { diff --git a/ngraph/test/runtime/opset0_tbl.hpp b/ngraph/test/runtime/opset0_tbl.hpp index c7b4af0526b..1526f735b2c 100644 --- a/ngraph/test/runtime/opset0_tbl.hpp +++ b/ngraph/test/runtime/opset0_tbl.hpp @@ -59,7 +59,6 @@ NGRAPH_OP(Atan, ngraph::op) NGRAPH_OP(AvgPool, ngraph::op::v0) NGRAPH_OP(BatchNormInference, ngraph::op) NGRAPH_OP(Broadcast, ngraph::op) -NGRAPH_OP(BroadcastDistributed, ngraph::op) NGRAPH_OP(BroadcastLike, ngraph::op) NGRAPH_OP(Ceiling, ngraph::op) NGRAPH_OP(Clamp, ngraph::op)