Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[onert] Configure context_data_map using the backend info of lgraph #12653

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions runtime/onert/core/src/compiler/ExecutorFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,18 +160,15 @@ createBackendContexts(compiler::ILoweredGraph &lgraph, bool linear_executor,
std::shared_ptr<backend::custom::IKernelBuilder> custom_kernel_builder)
{
backend::BackendContexts contexts;
auto &backend_manager = compiler::BackendManager::get();

std::unordered_map<const backend::Backend *, backend::ContextData> context_data_map;

// Generate partial graphs for each backend
for (auto &&backend : backend_manager.getAll())
{
auto init_context_data = [&](const backend::Backend *backend) {
auto &data = context_data_map[backend];
auto graph = std::make_unique<ir::Graph>();
graph->setLayout(lgraph.graph().layout());
data.graph = std::move(graph);
}
};

auto &whole_graph = lgraph.graph();
// Separate operands into partial graphs
Expand All @@ -182,6 +179,9 @@ createBackendContexts(compiler::ILoweredGraph &lgraph, bool linear_executor,
return;
const auto &def_factor = def_factors.getOnlyElement();
const auto backend = def_factor.backend();
if (context_data_map.find(backend) == context_data_map.end())
init_context_data(backend);

auto &partial_graph = *context_data_map[backend].graph;
auto &operand_layouts = context_data_map[backend].operand_layouts;
assert(operand_layouts.find(operand_ind) == operand_layouts.end());
Expand All @@ -200,6 +200,9 @@ createBackendContexts(compiler::ILoweredGraph &lgraph, bool linear_executor,
[&](const ir::OperationIndex &op_ind, const ir::IOperation &operation) {
auto &op_li = lgraph.lower_info().operation;
auto backend = op_li.at(op_ind).backend();
if (context_data_map.find(backend) == context_data_map.end())
init_context_data(backend);

auto &partial_graph = *context_data_map[backend].graph;
auto &external_operands = context_data_map[backend].external_operands;
auto &operand_layouts = context_data_map[backend].operand_layouts;
Expand Down
Loading