Skip to content

Commit

Permalink
fix: 分配器只为非全图输入、输出或局部的数据分配空间
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Oct 13, 2023
1 parent ceb3ee6 commit 37287ee
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/04kernel/src/allocator/flat_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ namespace refactor::kernel {
}

AllocScheme flatAllocate(graph_topo::Graph<Node, Edge> const &g) {
size_t size = 0;
std::vector<size_t> offsets(g.edges.size());
for (size_t i = 0; i < offsets.size(); ++i) {
offsets[i] = size;
size += align(g.edges[i].size, 8);
constexpr static auto INVALID = SIZE_MAX;
size_t size = 0,
globalInputsCount = g.topology.globalInputsCount();
auto globalOutputs_ = g.topology.globalOutputs();
std::unordered_set<size_t> globalOutputs(globalOutputs_.begin(), globalOutputs_.end());
std::vector<size_t> offsets(g.edges.size(), INVALID);
for (auto [nodeIdx, inputs, outputs] : g.topology) {
for (auto i : outputs) {
if (globalOutputs.find(i) == globalOutputs.end()) {
offsets[i] = size;
size += align(g.edges[i].size, 8);
}
}
}
return {size, std::move(offsets)};
}
Expand Down

0 comments on commit 37287ee

Please sign in to comment.