!10922 optimize somas logs

From: @laiyongqiang
Reviewed-by: 
Signed-off-by:
pull/10922/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit bb2870fe71

File diff suppressed because it is too large Load Diff

@ -29,6 +29,7 @@
#include "backend/optimizer/somas/somas_node.h"
#include "backend/optimizer/somas/somas_solver_pre.h"
#include "backend/optimizer/somas/somas_stream.h"
#include "backend/optimizer/somas/somas_parameter.h"
#include "backend/session/anf_runtime_algorithm.h"
#include "backend/session/kernel_graph.h"
@ -48,7 +49,7 @@ class Somas {
uint8_t *GetNodeOutputPtr(const AnfNodePtr &node, size_t index) const;
uint8_t *GetNodeWorkSpacePtr(const AnfNodePtr &node, size_t index) const;
void DumpSomasBasicIR(const string filename);
void DumpSomasInfoIR(const string filename);
void DumpSomasMemoryIR(const string filename);
static bool NodeSort(SomasNodePtr, SomasNodePtr);
@ -58,11 +59,13 @@ class Somas {
// Maps
std::unordered_map<size_t, SomasTensorPtr> tensors_map_;
std::map<void *, SomasNodePtr> nodes_map_;
std::map<void *, vector<SomasParameterPtr>> parameters_map_;
// Vectors
std::vector<SomasNodePtr> nodes_list_;
std::vector<SomasStreamPtr> streams_list_;
std::vector<SomasTensorPtr> tensors_list_;
std::vector<SomasParameterPtr> parameters_list_;
// Stream groups
std::vector<vector<uint32_t>> streams_groups_;
@ -120,7 +123,11 @@ class Somas {
void DumpSomasMemoryPoolInfoIR(const string filename);
std::string GetSplitName(const string &scope_name) const;
size_t CalcLowerBound() const;
void GenStatisticInfo();
void GenGraphStatisticInfo();
SomasParameterPtr GetSomasParameters(AnfNodePtr node, size_t index);
SomasParameterPtr CreateSomasParameters(AnfNodePtr node, size_t index);
void InitCommonNodeInputs(bool is_all_nop_node, const CNodePtr &kernel);
void InitAtomicCleanInputs(bool is_all_nop_node, const CNodePtr &kernel);
};
using SomasPtr = std::shared_ptr<Somas>;

@ -19,8 +19,10 @@
#include "backend/optimizer/somas/somas_stream.h"
#include "backend/optimizer/somas/somas_tensor.h"
#include "backend/optimizer/somas/somas_parameter.h"
#include <memory>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
@ -49,6 +51,7 @@ class SomasNode {
std::vector<SomasTensorPtr> input_tensors_;
std::vector<SomasTensorPtr> output_tensors_;
std::vector<SomasTensorPtr> workspace_tensors_;
std::map<size_t, SomasParameterPtr> input_parameters_map_;
std::unordered_map<int64_t, size_t> anc_stream_max_order_;

@ -0,0 +1,41 @@
/**
* Copyright 2021 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.
*/
#ifndef MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_PARAMETER_H_
#define MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_PARAMETER_H_
#include <memory>
#include "base/base.h"
namespace mindspore {
namespace somas {
class SomasParameter {
public:
SomasParameter(size_t id, AnfNodePtr source_node, size_t index, const void *addr, size_t size)
: id_(id), source_node_(source_node), output_index_(index), addr_(const_cast<void *>(addr)), size_(size) {}
~SomasParameter() = default;
const size_t id_{0};
AnfNodePtr source_node_;
size_t output_index_;
void *addr_;
size_t size_;
};
using SomasParameterPtr = std::shared_ptr<SomasParameter>;
} // namespace somas
} // namespace mindspore
#endif // MINDSPORE_CCSRC_BACKEND_OPTIMIZER_SOMAS_SOMAS_PARAMETER_H_

@ -73,9 +73,8 @@ void MemoryManager::MallocSomasDynamicMem(const session::KernelGraph *graph) {
save_graphs_path = ".";
}
if (save_graphs) {
std::string file_path =
save_graphs_path + "/" + "somas_after_allocate_" + std::to_string(graph->graph_id()) + ".ir";
somas_reuse_util_ptr_->DumpSomasBasicIR(file_path);
std::string file_path = save_graphs_path + "/" + "somas_allocate_info_" + std::to_string(graph->graph_id()) + ".ir";
somas_reuse_util_ptr_->DumpSomasInfoIR(file_path);
std::string mem_file_path = save_graphs_path + "/" + "somas_mem_info_" + std::to_string(graph->graph_id()) + ".ir";
somas_reuse_util_ptr_->DumpSomasMemoryIR(mem_file_path);

Loading…
Cancel
Save