diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas_node.cc b/mindspore/ccsrc/backend/optimizer/somas/somas_node.cc deleted file mode 100644 index 532b4fc605..0000000000 --- a/mindspore/ccsrc/backend/optimizer/somas/somas_node.cc +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - - * 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 "backend/optimizer/somas/somas_node.h" -#include - -namespace mindspore { -namespace somas { -void SomasNode::ComputeAncestorNodes() { - // Fast algorithm: assuming nodes execute this function in the received topological order - int64_t thisId = this->GetStream()->GetId(); - - for (SomasNodePtr node : ancestor_nodes_) { - int64_t ancestorId = node->GetStream()->GetId(); - // Map Improvement for max_ancestor_order - if (thisId != ancestorId) { - this->anc_stream_max_order_[ancestorId] = std::max(this->anc_stream_max_order_[ancestorId], node->GetId()); - } - for (SomasStreamPtr stream : node->GetStream()->ancestor_streams_) { - this->anc_stream_max_order_[stream->GetId()] = - std::max(this->anc_stream_max_order_[stream->GetId()], node->anc_stream_max_order_[stream->GetId()]); - } - } -} - -void SomasNode::PresetAncestorStreams(const std::vector stream_vector) { - for (SomasStreamPtr stream : stream_vector) { - anc_stream_max_order_[stream->GetId()] = 0; - } -} -} // namespace somas -} // namespace mindspore diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas_node.h b/mindspore/ccsrc/backend/optimizer/somas/somas_node.h index 64279fb7b1..fc127a1162 100644 --- a/mindspore/ccsrc/backend/optimizer/somas/somas_node.h +++ b/mindspore/ccsrc/backend/optimizer/somas/somas_node.h @@ -66,10 +66,6 @@ class SomasNode { SomasStreamPtr GetStream() { return stream_; } const NodeType &GetType() { return type_; } - // Computing ancestors - void PresetAncestorStreams(const std::vector stream_vector); - void ComputeAncestorNodes(); - private: const size_t id_{0}; SomasStreamPtr const stream_; diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas_stream.cc b/mindspore/ccsrc/backend/optimizer/somas/somas_stream.cc deleted file mode 100644 index 20cd8b1b3f..0000000000 --- a/mindspore/ccsrc/backend/optimizer/somas/somas_stream.cc +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - - * 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 "backend/optimizer/somas/somas_stream.h" - -namespace mindspore { -namespace somas { -void SomasStream::ComputeAncestorStreams() { - // (Naive) algorithm: for a given stream, compute its ancestors assuming only distance 1 ancestors are known (handles - // cycles between streams) - std::set current_level, temp_level, already_visited; - auto thisPtr = std::make_shared(id_); - already_visited.insert(thisPtr); - // Initialize current level to distance 2 ancestors - for (auto stream1 : ancestor_streams_) { - already_visited.insert(stream1); - for (auto stream2 : stream1->ancestor_streams_) { - if (std::find(already_visited.begin(), already_visited.end(), stream2) == already_visited.end()) - current_level.insert(stream2); - } - } - - while (!current_level.empty()) { - // Push current level into ancestors - for (auto stream1 : current_level) { - ancestor_streams_.insert(stream1); - already_visited.insert(stream1); - // Keep next level of this ancestor - for (auto stream2 : stream1->ancestor_streams_) { - if (std::find(already_visited.begin(), already_visited.end(), stream2) == already_visited.end()) - temp_level.insert(stream2); - } - } - current_level.clear(); - current_level = temp_level; - temp_level.clear(); - } -} -} // namespace somas -} // namespace mindspore diff --git a/mindspore/ccsrc/backend/optimizer/somas/somas_stream.h b/mindspore/ccsrc/backend/optimizer/somas/somas_stream.h index c924eb47de..2c6f9ccdfc 100644 --- a/mindspore/ccsrc/backend/optimizer/somas/somas_stream.h +++ b/mindspore/ccsrc/backend/optimizer/somas/somas_stream.h @@ -51,9 +51,6 @@ class SomasStream { // Accessors const int64_t &GetId() const { return id_; } - // Ancestor Computing - void ComputeAncestorStreams(); // Given "ancestors at distance one" information, compute "ancestors at any distance" - private: const int64_t id_{0}; };