diff --git a/runtime/onert/core/src/compiler/ExecutorFactory.cc b/runtime/onert/core/src/compiler/ExecutorFactory.cc index 9d85ee8baf7..270e43def3f 100644 --- a/runtime/onert/core/src/compiler/ExecutorFactory.cc +++ b/runtime/onert/core/src/compiler/ExecutorFactory.cc @@ -157,15 +157,25 @@ void initializeSubgraphIOTensors(compiler::ILoweredGraph &lowered_graph, backend::BackendContexts createBackendContexts(compiler::ILoweredGraph &lgraph, bool linear_executor, - std::shared_ptr custom_kernel_builder) + std::shared_ptr custom_kernel_builder, + const std::vector &backend_list) { backend::BackendContexts contexts; auto &backend_manager = compiler::BackendManager::get(); std::unordered_map context_data_map; + std::vector 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(); @@ -391,8 +401,8 @@ ExecutorFactory::createLinearExecutor(std::unique_ptr 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}; @@ -525,8 +535,8 @@ ExecutorFactory::createDataflowExecutor(std::unique_ptr 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}; @@ -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)