fix user set npu check

This commit is contained in:
zhaozhenlong 2021-04-27 11:09:49 +08:00
parent 55bdb33f35
commit 9ec5888bd9
1 changed files with 4 additions and 1 deletions

View File

@ -36,11 +36,14 @@ InnerContext::InnerContext(const Context *context) {
InnerContext::InnerContext(const Context *context, NPUManager *npu_manager) {
this->allocator = context->allocator;
this->thread_num_ = context->thread_num_;
bool isUserSetNPU = context->device_list_.end() !=
std::find_if(context->device_list_.begin(), context->device_list_.end(),
[](const DeviceContext &device) { return device.device_type_ == DT_NPU; });
this->device_list_.clear();
for (auto &device_ctx : context->device_list_) {
// 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()) {
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);