From a40984e1bfdbd6c0a410e02450c15b17c7c96f35 Mon Sep 17 00:00:00 2001 From: zhaozhenlong Date: Fri, 16 Apr 2021 10:42:15 +0800 Subject: [PATCH] when run npu, cpu op not bind core --- mindspore/lite/src/inner_context.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mindspore/lite/src/inner_context.cc b/mindspore/lite/src/inner_context.cc index 29dfeab99f..a4a1a6e73a 100644 --- a/mindspore/lite/src/inner_context.cc +++ b/mindspore/lite/src/inner_context.cc @@ -38,7 +38,15 @@ InnerContext::InnerContext(const Context *context, NPUManager *npu_manager) { this->thread_num_ = context->thread_num_; this->device_list_.clear(); for (auto &device_ctx : context->device_list_) { - this->device_list_.push_back(device_ctx); + // npu server would use one core so we don't bind core to avoid competition. + // If user does not set npu device, we still bind core. + if (device_ctx.device_type_ == DT_CPU && IsUserSetNpu()) { + auto cpu_ctx = device_ctx; + cpu_ctx.device_info_.cpu_device_info_.cpu_bind_mode_ = NO_BIND; + this->device_list_.push_back(cpu_ctx); + } else { + this->device_list_.push_back(device_ctx); + } } this->npu_manager_ = npu_manager; }