commit
c9a4b65720
@ -0,0 +1,234 @@
|
||||
/**
|
||||
* 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 "graph/build/memory/buffer_pool_mem_assigner.h"
|
||||
#include "graph/common/omg_util.h"
|
||||
#include "graph/utils/tensor_utils.h"
|
||||
#include "framework/common/util.h"
|
||||
#include "graph/compute_graph.h"
|
||||
#include "graph/debug/ge_attr_define.h"
|
||||
#include "common/math/math_util.h"
|
||||
#include "common/util/error_manager/error_manager.h"
|
||||
|
||||
namespace ge {
|
||||
namespace {
|
||||
const size_t kBufferPoolNodeMemInfoLength = 2;
|
||||
const uint32_t kBufferPoolNodeOutputSizeIndex = 0;
|
||||
const uint32_t kBufferPoolNodeOutputOffsetIndex = 1;
|
||||
} // namespace
|
||||
|
||||
Status BufferPoolMemAssigner::Assign() {
|
||||
if (compute_graph_ == nullptr) {
|
||||
GELOGE(PARAM_INVALID, "[Check][Graph]Graph is nullptr");
|
||||
REPORT_INNER_ERROR("E19999", "Input graph is nullptr");
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
Status ret = InitAssigner(compute_graph_);
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(FAILED, "[Init][Assigner]Graph:%s.", compute_graph_->GetName().c_str());
|
||||
return FAILED;
|
||||
}
|
||||
ret = AssignOutput();
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(FAILED, "[Assign][Output]Graph:%s.", compute_graph_->GetName().c_str());
|
||||
return FAILED;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Status BufferPoolMemAssigner::GetOutputMemoryType(const NodePtr &node, size_t idx, int64_t &memory_type) {
|
||||
GE_CHECK_NOTNULL(node->GetOpDesc());
|
||||
memory_type = RT_MEMORY_HBM;
|
||||
std::vector<int64_t> type_list;
|
||||
bool has_mem_type = ge::AttrUtils::GetListInt(node->GetOpDesc(), ATTR_NAME_OUTPUT_MEM_TYPE_LIST, type_list);
|
||||
if (has_mem_type && (type_list.size() != node->GetOpDesc()->GetOutputsSize() || idx >= type_list.size())) {
|
||||
GELOGE(PARAM_INVALID, "[Check][OutputParam]Output param invalid, output size:%zu, mem type size:%zu, index:%zu.",
|
||||
node->GetOpDesc()->GetOutputsSize(), type_list.size(), idx);
|
||||
REPORT_INNER_ERROR("E19999", "Output param invalid, output size:%zu, mem type size:%zu, index:%zu.",
|
||||
node->GetOpDesc()->GetOutputsSize(), type_list.size(), idx);
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
memory_type = has_mem_type ? type_list[idx] : RT_MEMORY_HBM;
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Status BufferPoolMemAssigner::InitAssigner(const ComputeGraphPtr &graph) {
|
||||
for (const NodePtr &node : graph->GetAllNodes()) {
|
||||
int64_t buffer_pool_id = 0;
|
||||
int64_t buffer_pool_size = 0;
|
||||
bool get_attr = AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_BUFFER_POOL_ID, buffer_pool_id);
|
||||
get_attr = get_attr && (AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_BUFFER_POOL_SIZE, buffer_pool_size));
|
||||
if (get_attr) {
|
||||
std::string batch_label;
|
||||
(void) AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_BATCH_LABEL, batch_label);
|
||||
buffer_pool_nodes_[batch_label][buffer_pool_id].emplace_back(node);
|
||||
auto iter = buffer_pool_size_[batch_label].find(buffer_pool_id);
|
||||
if (iter == buffer_pool_size_[batch_label].end()) {
|
||||
buffer_pool_size_[batch_label][buffer_pool_id] = buffer_pool_size;
|
||||
}
|
||||
Status ret = InitMemOffsetBase(node);
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(ret, "[Init][MemOffsetBase]Batch label:%s.", batch_label.c_str());
|
||||
REPORT_INNER_ERROR("E19999", "Failed to init offset base, batch label:%s.", batch_label.c_str());
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t max_size = 0;
|
||||
for (const auto &iter : buffer_pool_size_) {
|
||||
std::string batch_label = iter.first;
|
||||
int64_t batch_offset = mem_offset_base_;
|
||||
for (const auto &buffer_pool : iter.second) {
|
||||
int64_t buffer_pool_id = buffer_pool.first;
|
||||
int64_t buffer_pool_size = buffer_pool.second;
|
||||
buffer_pool_offset_base_[batch_label][buffer_pool_id] = batch_offset;
|
||||
FMK_INT64_ADDCHECK(buffer_pool_size, kBufferPoolMemAlignSize);
|
||||
AlignMemSize(buffer_pool_size, kBufferPoolMemAlignSize);
|
||||
FMK_INT64_ADDCHECK(batch_offset, (buffer_pool_size + kBufferPoolMemAlignSize));
|
||||
batch_offset += (buffer_pool_size + kBufferPoolMemAlignSize);
|
||||
}
|
||||
int64_t batch_mem_size = batch_offset - mem_offset_base_;
|
||||
GELOGI("[Init][Assigner]Get batch mem size, batch label:%s, mem size:%ld.", batch_label.c_str(), batch_mem_size);
|
||||
if (max_size < batch_mem_size) {
|
||||
max_size = batch_mem_size;
|
||||
}
|
||||
}
|
||||
FMK_INT64_ADDCHECK(mem_offset_base_, max_size);
|
||||
mem_offset_ = static_cast<size_t>(mem_offset_base_ + max_size);
|
||||
GELOGI("[Init][Assigner]Init buffer pool mem assigner successfully, "
|
||||
"mem type:%ld, mem offset base:%ld, mem offset:%zu.", mem_type_, mem_offset_base_, mem_offset_);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Status BufferPoolMemAssigner::InitMemOffsetBase(const NodePtr &node) {
|
||||
int64_t mem_type;
|
||||
Status ret = GetOutputMemoryType(node, static_cast<size_t>(kBufferPoolNodeOutIndex), mem_type);
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(ret, "[Get][MemType]Node:%s, index:%u.", node->GetName().c_str(), kBufferPoolNodeOutIndex);
|
||||
REPORT_INNER_ERROR("E19999", "Failed to get output memory type, node:%s, index:%u.",
|
||||
node->GetName().c_str(), kBufferPoolNodeOutIndex);
|
||||
return ret;
|
||||
}
|
||||
if (mem_type_ != mem_type && init_offset_base_) {
|
||||
GELOGE(PARAM_INVALID, "[Check][MemType]The memory type of all buffer pool nodes must be the same, node:%s, "
|
||||
"required:%ld, actually: %ld", node->GetName().c_str(), mem_type_, mem_type);
|
||||
REPORT_INNER_ERROR("E19999", "The memory type of all buffer pool nodes must be the same, node:%s, "
|
||||
"required:%ld, actually: %ld", node->GetName().c_str(), mem_type_, mem_type);
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
if (!init_offset_base_) {
|
||||
auto iter = mem_type_to_offset_.find(mem_type);
|
||||
if (iter == mem_type_to_offset_.end()) {
|
||||
GELOGE(PARAM_INVALID, "[Check][MemType]Memory type is not supported, node:%s, mem type:%ld.",
|
||||
node->GetName().c_str(), mem_type);
|
||||
REPORT_INNER_ERROR("E19999", "Memory type is not supported, node:%s, mem type:%ld.",
|
||||
node->GetName().c_str(), mem_type);
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
mem_offset_base_ = static_cast<int64_t>(iter->second);
|
||||
FMK_INT64_ADDCHECK(mem_offset_base_, (kBufferPoolMemAlignSize + kBufferPoolMemAlignSize));
|
||||
AlignMemSize(mem_offset_base_, kBufferPoolMemAlignSize);
|
||||
// The HCOM nodes may access the previous 512 bytes.
|
||||
mem_offset_base_ += kBufferPoolMemAlignSize;
|
||||
mem_type_ = mem_type;
|
||||
init_offset_base_ = true;
|
||||
GELOGI("[Init][MemOffsetBase]Init offset base:%ld, memory type:%ld", mem_offset_base_, mem_type);
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Status BufferPoolMemAssigner::AssignOutput() {
|
||||
for (auto &batch_pool_nodes_map : buffer_pool_nodes_) {
|
||||
std::string batch_label = batch_pool_nodes_map.first;
|
||||
for (auto &pool_nodes_map : batch_pool_nodes_map.second) {
|
||||
int64_t buffer_pool_id = pool_nodes_map.first;
|
||||
auto iter_buffer_id_size = buffer_pool_size_[batch_label].find(buffer_pool_id);
|
||||
if (iter_buffer_id_size == buffer_pool_size_[batch_label].end()) {
|
||||
GELOGE(INTERNAL_ERROR, "[Get][BufferPoolSize]Pool id:%ld.", buffer_pool_id);
|
||||
REPORT_INNER_ERROR("E19999", "Failed to get buffer pool size, pool id:%ld.", buffer_pool_id);
|
||||
return INTERNAL_ERROR;
|
||||
}
|
||||
auto iter_buffer_id_offset = buffer_pool_offset_base_[batch_label].find(buffer_pool_id);
|
||||
if (iter_buffer_id_offset == buffer_pool_offset_base_[batch_label].end()) {
|
||||
GELOGE(INTERNAL_ERROR, "[Get][BufferPoolBaseOffset]Pool id:%ld.", buffer_pool_id);
|
||||
REPORT_INNER_ERROR("E19999", "Failed to get buffer pool base offset, pool id:%ld.", buffer_pool_id);
|
||||
return INTERNAL_ERROR;
|
||||
}
|
||||
int64_t buffer_pool_size = iter_buffer_id_size->second;
|
||||
int64_t output_offset_base = iter_buffer_id_offset->second;
|
||||
Status ret = AssignOutputInOneBufferPool(batch_label, output_offset_base, pool_nodes_map.second);
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(ret, "[Assign][OneBufferPool]Batch label:%s, pool id:%ld, pool size:%ld, offset base:%ld.",
|
||||
batch_label.c_str(), buffer_pool_id, buffer_pool_size, output_offset_base);
|
||||
REPORT_INNER_ERROR("E19999", "Failed to assign output memory, batch label:%s, "
|
||||
"pool id:%ld, pool size:%ld, offset base:%ld.",
|
||||
batch_label.c_str(), buffer_pool_id, buffer_pool_size, output_offset_base);
|
||||
return ret;
|
||||
}
|
||||
GELOGI("[Assign][Output]Assign output successfully, batch label:%s, pool id:%ld, pool size:%ld, offset base:%ld.",
|
||||
batch_label.c_str(), buffer_pool_id, buffer_pool_size, output_offset_base);
|
||||
}
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
Status BufferPoolMemAssigner::AssignOutputInOneBufferPool(const std::string &batch_label,
|
||||
int64_t output_offset_base,
|
||||
const std::vector<NodePtr> &buffer_pool_nodes) {
|
||||
for (const NodePtr &node : buffer_pool_nodes) {
|
||||
int64_t output_size = 0;
|
||||
Status ret = GetMemorySize(node, output_size);
|
||||
if (ret != SUCCESS) {
|
||||
GELOGE(ret, "[Get][MemSize]Node:%s.", node->GetName().c_str());
|
||||
REPORT_INNER_ERROR("E19999", "Failed to get output size, node:%s.", node->GetName().c_str());
|
||||
return ret;
|
||||
}
|
||||
OpDescPtr op_desc = node->GetOpDesc();
|
||||
GE_CHECK_NOTNULL(op_desc);
|
||||
vector<int64_t> memory_size_and_offset;
|
||||
bool get_attr = AttrUtils::GetListInt(op_desc, ATTR_NAME_BUFFER_POOL_NODE_SIZE_AND_OFFSET, memory_size_and_offset);
|
||||
if (!get_attr || memory_size_and_offset.size() != kBufferPoolNodeMemInfoLength) {
|
||||
GELOGE(PARAM_INVALID, "[Get][Attr]Node:%s, mem info size:%zu, required size:%zu.",
|
||||
node->GetName().c_str(), memory_size_and_offset.size(), kBufferPoolNodeMemInfoLength);
|
||||
REPORT_INNER_ERROR("E19999", "Failed to get pool node memory info, node:%s, info size:%zu, required size:%zu.",
|
||||
node->GetName().c_str(), memory_size_and_offset.size(), kBufferPoolNodeMemInfoLength);
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
if (output_size != memory_size_and_offset[kBufferPoolNodeOutputSizeIndex]) {
|
||||
GELOGE(PARAM_INVALID, "[Check][MemSize]Something wrong with memory size, pre size:%ld, curr size:%ld, node:%s.",
|
||||
memory_size_and_offset[kBufferPoolNodeOutputSizeIndex], output_size, node->GetName().c_str());
|
||||
REPORT_INNER_ERROR("E19999", "Something wrong with memory size, pre size:%ld, curr size:%ld, node:%s.",
|
||||
memory_size_and_offset[kBufferPoolNodeOutputSizeIndex], output_size, node->GetName().c_str());
|
||||
return PARAM_INVALID;
|
||||
}
|
||||
|
||||
int64_t logical_offset = memory_size_and_offset[kBufferPoolNodeOutputOffsetIndex];
|
||||
vector<int64_t> output_list = {(output_offset_base + logical_offset)};
|
||||
op_desc->SetOutputOffset(output_list);
|
||||
// log for IMAS tools
|
||||
GELOGI("[IMAS]Set %s name[%s] optype[%s] %s[%u] offset to [%ld] streamid[%ld] memtype[%ld] "
|
||||
"size[%zu] realsize[%zu] noalignsize[%zu] life time begin[%d] life time end[%d] "
|
||||
"child[%d:%d:%d:%d:%d] isref[%d] batch[%s]",
|
||||
compute_graph_->GetName().c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
|
||||
"output", kBufferPoolNodeOutIndex, output_list[kBufferPoolNodeOutIndex], op_desc->GetStreamId(), mem_type_,
|
||||
static_cast<size_t>(output_size), static_cast<size_t>(output_size), static_cast<size_t>(output_size),
|
||||
0, 0, 0, 0, 0, 0, 0, 0, batch_label.c_str());
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
} // namespace ge
|
@ -0,0 +1,83 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GE_GRAPH_BUILD_MEMORY_BUFFER_POOL_MEM_ASSIGNER_H_
|
||||
#define GE_GRAPH_BUILD_MEMORY_BUFFER_POOL_MEM_ASSIGNER_H_
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <unordered_map>
|
||||
#include "graph/build/memory/mem_assigner.h"
|
||||
#include "runtime/mem.h"
|
||||
|
||||
namespace ge {
|
||||
class BufferPoolMemAssigner : public MemAssigner {
|
||||
public:
|
||||
BufferPoolMemAssigner(ComputeGraphPtr compute_graph, const std::map<int64_t, size_t> &mem_type_to_offset)
|
||||
: MemAssigner(), compute_graph_(compute_graph),
|
||||
mem_type_(0),
|
||||
mem_offset_(0),
|
||||
mem_offset_base_(0),
|
||||
init_offset_base_(false),
|
||||
mem_type_to_offset_(mem_type_to_offset) {}
|
||||
|
||||
BufferPoolMemAssigner(const BufferPoolMemAssigner &) = delete;
|
||||
|
||||
BufferPoolMemAssigner &operator=(const BufferPoolMemAssigner &) = delete;
|
||||
|
||||
~BufferPoolMemAssigner() override = default;
|
||||
|
||||
Status Assign() override;
|
||||
|
||||
size_t GetMemOffset() const { return mem_offset_; }
|
||||
|
||||
int64_t GetMemType() const { return mem_type_; }
|
||||
|
||||
private:
|
||||
static Status GetOutputMemoryType(const NodePtr &node, size_t idx, int64_t &memory_type);
|
||||
|
||||
Status InitAssigner(const ComputeGraphPtr &graph);
|
||||
|
||||
Status InitMemOffsetBase(const NodePtr &node);
|
||||
|
||||
Status AssignOutput();
|
||||
|
||||
Status AssignOutputInOneBufferPool(const std::string &batch_label,
|
||||
int64_t output_offset_base,
|
||||
const std::vector<NodePtr> &buffer_pool_nodes);
|
||||
|
||||
ComputeGraphPtr compute_graph_;
|
||||
|
||||
int64_t mem_type_;
|
||||
|
||||
size_t mem_offset_;
|
||||
|
||||
int64_t mem_offset_base_;
|
||||
|
||||
bool init_offset_base_;
|
||||
|
||||
std::map<int64_t, size_t> mem_type_to_offset_;
|
||||
|
||||
// Use map to ensure that each visit is in the order of pool id
|
||||
std::unordered_map<std::string, std::map<int64_t, std::vector<NodePtr>>> buffer_pool_nodes_;
|
||||
|
||||
// Use map to ensure that each visit is in the order of pool id
|
||||
std::unordered_map<std::string, std::map<int64_t, int64_t>> buffer_pool_size_;
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<int64_t, int64_t>> buffer_pool_offset_base_;
|
||||
};
|
||||
} // namespace ge
|
||||
#endif // GE_GRAPH_BUILD_MEMORY_BUFFER_POOL_MEM_ASSIGNER_H_
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,136 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GE_GRAPH_PASSES_BUFFER_POOL_MEMORY_PASS_H_
|
||||
#define GE_GRAPH_PASSES_BUFFER_POOL_MEMORY_PASS_H_
|
||||
|
||||
#include <queue>
|
||||
#include "graph/graph.h"
|
||||
#include "inc/graph_pass.h"
|
||||
|
||||
namespace ge {
|
||||
class BufferPoolMemoryPass : public GraphPass {
|
||||
public:
|
||||
explicit BufferPoolMemoryPass() : logic_event_num_(0) {}
|
||||
|
||||
~BufferPoolMemoryPass() override = default;
|
||||
|
||||
struct BufferPool {
|
||||
int64_t pool_id = 0;
|
||||
int64_t pool_size = 0;
|
||||
std::unordered_map<NodePtr, NodePtr> buffer_node_to_calc;
|
||||
BufferPool(int64_t id, int64_t size, const std::unordered_map<NodePtr, NodePtr> &node_map)
|
||||
: pool_id(id), pool_size(size), buffer_node_to_calc(node_map) {}
|
||||
};
|
||||
|
||||
struct BufferPoolNodeItem {
|
||||
NodePtr node = nullptr;
|
||||
NodePtr out_calc_node = nullptr;
|
||||
NodePtr pre_buffer_pool_node = nullptr;
|
||||
int64_t total_size = 0;
|
||||
int64_t offset_start = 0;
|
||||
int64_t offset_end = 0;
|
||||
bool is_last_input = true;
|
||||
BufferPoolNodeItem(const NodePtr &buffer_n, const NodePtr &calc_n, const NodePtr &pre_buffer_n,
|
||||
int64_t size, int64_t start, int64_t end, bool last)
|
||||
: node(std::move(buffer_n)),
|
||||
out_calc_node(std::move(calc_n)),
|
||||
pre_buffer_pool_node(std::move(pre_buffer_n)),
|
||||
total_size(size),
|
||||
offset_start(start),
|
||||
offset_end(end),
|
||||
is_last_input(last) {}
|
||||
|
||||
BufferPoolNodeItem(const NodePtr &buffer_n, int64_t start, int64_t end)
|
||||
: node(std::move(buffer_n)),
|
||||
out_calc_node(nullptr),
|
||||
pre_buffer_pool_node(nullptr),
|
||||
total_size(0),
|
||||
offset_start(start),
|
||||
offset_end(end),
|
||||
is_last_input(true) {}
|
||||
};
|
||||
|
||||
Status Run(ComputeGraphPtr graph) override;
|
||||
|
||||
private:
|
||||
static void ClearQueue(std::queue<std::pair<std::string, uint32_t>> &q);
|
||||
|
||||
static Status IsBufferPoolMemEnable(const ComputeGraphPtr &graph);
|
||||
|
||||
static Status CheckBufferPoolSize(int64_t total_size, int64_t pool_id, int64_t buffer_pool_size,
|
||||
std::unordered_map<int64_t, int64_t> &calc_total_size);
|
||||
|
||||
static Status TryToFixNodeOrder(NodePtr &pre_node, NodePtr &curr_node, bool ¬_change);
|
||||
|
||||
Status InsertMemCpyNodeAfter(ComputeGraphPtr &graph, NodePtr &node);
|
||||
|
||||
Status CopyOutForMultiUsedOutput(ComputeGraphPtr &graph);
|
||||
|
||||
Status GetBufferPoolAndPeerCalcNodes(const ComputeGraphPtr &graph);
|
||||
|
||||
Status SetBufferPoolSize(const std::string &batch_label, int64_t id, int64_t size);
|
||||
|
||||
Status AllocateAllBufferPoolSpace();
|
||||
|
||||
Status AllocateSpaceInBatch(const std::map<int64_t, std::vector<NodePtr>> &calc_nodes,
|
||||
const std::unordered_map<int64_t, int64_t> &buffer_pool_size_map,
|
||||
const std::unordered_map<NodePtr, NodePtr> &buffer_node_to_calc,
|
||||
std::unordered_map<NodePtr, std::vector<BufferPoolNodeItem>> &buffer_pool_nodes_item);
|
||||
|
||||
Status AllocateSpaceInBufferPool(const BufferPool &buffer_pool,
|
||||
const std::vector<NodePtr> &calc_nodes_in_pool,
|
||||
std::unordered_map<NodePtr, std::vector<BufferPoolNodeItem>> &buffer_pool_nodes_item);
|
||||
|
||||
Status AllocateSpaceForBufferPoolNode(int64_t &next_start,
|
||||
const BufferPool buffer_pool,
|
||||
BufferPoolNodeItem &buffer_pool_node_item,
|
||||
std::queue<BufferPoolNodeItem> &node_mem_range_in_pool);
|
||||
|
||||
NodePtr GetOffsetAndDependency(int64_t &next_start,
|
||||
int64_t total_mem_size,
|
||||
int64_t buffer_pool_size,
|
||||
const std::unordered_map<NodePtr, NodePtr> &buffer_node_to_calc,
|
||||
std::queue<BufferPoolNodeItem> &nodes_in_buffer);
|
||||
|
||||
Status FixTheTimingOfDependentNodes(NodePtr &dependent_calc_node, NodePtr &curr_pool_node);
|
||||
|
||||
uint32_t GenerateEventId(const std::string &node_name, std::queue<std::pair<std::string, uint32_t>> &event_queue);
|
||||
|
||||
Status SetResultOfMemoryAndEvent();
|
||||
|
||||
// Use map to ensure that each visit is in the order of batch label and pool id
|
||||
std::map<std::string, std::map<int64_t, std::vector<NodePtr>>> calc_nodes_;
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<NodePtr, NodePtr>> buffer_node_to_calc_;
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<NodePtr, std::vector<BufferPoolNodeItem>>> peer_buffer_node_item_;
|
||||
|
||||
std::unordered_map<std::string, std::unordered_map<int64_t, int64_t>> buffer_pool_size_;
|
||||
|
||||
uint32_t logic_event_num_;
|
||||
|
||||
std::queue<std::pair<std::string, uint32_t>> mem_ctrl_event_;
|
||||
|
||||
std::queue<std::pair<std::string, uint32_t>> stream_ctrl_event_;
|
||||
|
||||
std::unordered_map<NodePtr, std::vector<std::string>> node_event_multiplexing_;
|
||||
|
||||
std::unordered_map<NodePtr, std::vector<int64_t>> buffer_node_logical_offset_;
|
||||
};
|
||||
} // namespace ge
|
||||
|
||||
#endif // GE_GRAPH_PASSES_BUFFER_POOL_MEMORY_PASS_H_
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue