!11754 [MS][LITE][Develop]fix context error for unfied API

From: @lx0095
Reviewed-by: @zhang_xue_tong,@zhanghaibo5
Signed-off-by: @zhang_xue_tong
pull/11754/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit d436b9ee98

@ -121,9 +121,9 @@ void CPUDeviceInfo::SetThreadAffinity(int affinity) {
int CPUDeviceInfo::GetThreadAffinity() const {
if (data_ == nullptr) {
MS_LOG(ERROR) << "Invalid context.";
return false;
return 0;
}
return GetValue<bool>(data_, kModelOptionCpuThreadAffinity);
return GetValue<int>(data_, kModelOptionCpuThreadAffinity);
}
void MaliGPUDeviceInfo::SetEnableFP16(bool is_fp16) {

@ -95,12 +95,12 @@ Status ModelImpl::Build() {
lite::DeviceInfo cpu_info = {.cpu_device_info_ = {cpu_context->GetEnableFP16(), mode}};
model_context.device_list_.push_back({lite::DT_CPU, cpu_info});
if (device_list.size() == 2) {
if (device_list[0]->GetDeviceType() == kMaliGPU) {
auto gpu_context = device_list[0]->Cast<MaliGPUDeviceInfo>();
if (device_list[1]->GetDeviceType() == kMaliGPU) {
auto gpu_context = device_list[1]->Cast<MaliGPUDeviceInfo>();
lite::DeviceInfo gpu_info = {.gpu_device_info_ = {gpu_context->GetEnableFP16()}};
model_context.device_list_.push_back({lite::DT_GPU, gpu_info});
} else if (device_list[0]->GetDeviceType() == kKirinNPU) {
auto npu_context = device_list[0]->Cast<KirinNPUDeviceInfo>();
} else if (device_list[1]->GetDeviceType() == kKirinNPU) {
auto npu_context = device_list[1]->Cast<KirinNPUDeviceInfo>();
lite::DeviceInfo npu_info = {.npu_device_info_ = {npu_context->GetFrequency()}};
model_context.device_list_.push_back({lite::DT_NPU, npu_info});
} else {

Loading…
Cancel
Save