Parallel onednn graph compilation GPU (#9958)

This commit is contained in:
Pavel Durandin 2022-01-27 19:47:24 +03:00 committed by GitHub
parent 622027bee5
commit d4779bb351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,35 +28,27 @@ void compile_graph::run(program& p) {
}
}
if (p.get_engine().get_device_info().supports_immad) {
for (auto& node : p.get_processing_order()) {
if (!node->is_type<data>() && !(node->is_type<mutable_data>() && node->get_dependencies().empty())) {
node->selected_impl = node->type()->choose_impl(*node);
}
}
} else {
auto task_executor = p.get_engine().get_task_executor();
auto& proc_order = p.get_processing_order();
std::vector<InferenceEngine::Task> tasks;
std::exception_ptr exception;
for (int idx = 0; idx < proc_order.size(); idx++) {
auto& node = *(std::next(proc_order.begin(), idx));
if (!node->is_type<data>() && !(node->is_type<mutable_data>() && node->get_dependencies().empty())) {
tasks.push_back([node, &exception] {
try {
node->selected_impl = node->type()->choose_impl(*node);
} catch(...) {
exception = std::current_exception();
}
});
}
}
task_executor->runAndWait(tasks);
tasks.clear();
if (exception) {
std::rethrow_exception(exception);
auto task_executor = p.get_engine().get_task_executor();
auto& proc_order = p.get_processing_order();
std::vector<InferenceEngine::Task> tasks;
std::exception_ptr exception;
for (int idx = 0; idx < proc_order.size(); idx++) {
auto& node = *(std::next(proc_order.begin(), idx));
if (!node->is_type<data>() && !(node->is_type<mutable_data>() && node->get_dependencies().empty())) {
tasks.push_back([node, &exception] {
try {
node->selected_impl = node->type()->choose_impl(*node);
} catch(...) {
exception = std::current_exception();
}
});
}
}
task_executor->runAndWait(tasks);
tasks.clear();
if (exception) {
std::rethrow_exception(exception);
}
}