Browse Source

remove useless code in SOMAS

pull/15395/head
laiyongqiang 4 years ago
parent
commit
3f7f88c0e0
4 changed files with 0 additions and 105 deletions
  1. +0
    -45
      mindspore/ccsrc/backend/optimizer/somas/somas_node.cc
  2. +0
    -4
      mindspore/ccsrc/backend/optimizer/somas/somas_node.h
  3. +0
    -53
      mindspore/ccsrc/backend/optimizer/somas/somas_stream.cc
  4. +0
    -3
      mindspore/ccsrc/backend/optimizer/somas/somas_stream.h

+ 0
- 45
mindspore/ccsrc/backend/optimizer/somas/somas_node.cc View File

@@ -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 <algorithm>

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<SomasStreamPtr> stream_vector) {
for (SomasStreamPtr stream : stream_vector) {
anc_stream_max_order_[stream->GetId()] = 0;
}
}
} // namespace somas
} // namespace mindspore

+ 0
- 4
mindspore/ccsrc/backend/optimizer/somas/somas_node.h View File

@@ -66,10 +66,6 @@ class SomasNode {
SomasStreamPtr GetStream() { return stream_; }
const NodeType &GetType() { return type_; }

// Computing ancestors
void PresetAncestorStreams(const std::vector<SomasStreamPtr> stream_vector);
void ComputeAncestorNodes();

private:
const size_t id_{0};
SomasStreamPtr const stream_;


+ 0
- 53
mindspore/ccsrc/backend/optimizer/somas/somas_stream.cc View File

@@ -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<SomasStreamPtr> current_level, temp_level, already_visited;
auto thisPtr = std::make_shared<SomasStream>(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

+ 0
- 3
mindspore/ccsrc/backend/optimizer/somas/somas_stream.h View File

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


Loading…
Cancel
Save