Skip to content

Commit

Permalink
[onert] Create a backend only for the ones in BACKENDS config
Browse files Browse the repository at this point in the history
This commit creates a backend only for the ones in BACKENDS config.

ONE-DCO-1.0-Signed-off-by: Jiyoung Yun <[email protected]>
  • Loading branch information
jyoungyun committed Feb 19, 2024
1 parent 3e47760 commit 4100ef6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions runtime/onert/core/src/compiler/ExecutorFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,25 @@ void initializeSubgraphIOTensors(compiler::ILoweredGraph &lowered_graph,

backend::BackendContexts
createBackendContexts(compiler::ILoweredGraph &lgraph, bool linear_executor,
std::shared_ptr<backend::custom::IKernelBuilder> custom_kernel_builder)
std::shared_ptr<backend::custom::IKernelBuilder> custom_kernel_builder,
const std::vector<std::string> &backend_list)
{
backend::BackendContexts contexts;
auto &backend_manager = compiler::BackendManager::get();

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

std::vector<const backend::Backend *> backends;
for (const auto &backend_name : backend_list)
{
auto backend = backend_manager.get(backend_name);
if (backend)
backends.push_back(backend);
}
backends.push_back(backend_manager.getBuiltin());

// Generate partial graphs for each backend
for (auto &&backend : backend_manager.getAll())
for (auto &&backend : backends)
{
auto &data = context_data_map[backend];
auto graph = std::make_unique<ir::Graph>();
Expand Down Expand Up @@ -391,8 +401,8 @@ ExecutorFactory::createLinearExecutor(std::unique_ptr<compiler::LoweredGraph> lo
auto custom_kernel_builder = args.custom_kernel_builder;
auto &graph = lowered_graph->graph();

backend::BackendContexts backend_contexts =
createBackendContexts(*lowered_graph, options->executor == "Linear", custom_kernel_builder);
backend::BackendContexts backend_contexts = createBackendContexts(
*lowered_graph, options->executor == "Linear", custom_kernel_builder, options->backend_list);

TensorRegistries tensor_regs{backend_contexts, true};

Expand Down Expand Up @@ -525,8 +535,8 @@ ExecutorFactory::createDataflowExecutor(std::unique_ptr<compiler::LoweredGraph>
const auto tracing_ctx = args.tracing_ctx;
auto custom_kernel_builder = args.custom_kernel_builder;

backend::BackendContexts backend_contexts =
createBackendContexts(*lowered_graph, options->executor == "Linear", custom_kernel_builder);
backend::BackendContexts backend_contexts = createBackendContexts(
*lowered_graph, options->executor == "Linear", custom_kernel_builder, options->backend_list);

TensorRegistries tensor_regs{backend_contexts, true};

Expand Down Expand Up @@ -672,7 +682,7 @@ exec::IExecutor *ExecutorFactory::createTrainableExecutor(
// TODO Create context only once instead of replacing
backend::train::TrainableBackendContexts tbackend_contexts;
backend::BackendContexts base_backend_contexts =
createBackendContexts(*lowered_graph, true, custom_kernel_builder);
createBackendContexts(*lowered_graph, true, custom_kernel_builder, options->backend_list);

// Replace BackendContext with TrainbleBackendContext
for (auto &&pair : base_backend_contexts)
Expand Down

0 comments on commit 4100ef6

Please sign in to comment.