From 1b1351fa17c884ab77c5271cc0e368d2b55c124d Mon Sep 17 00:00:00 2001 From: kswang Date: Sat, 25 Jul 2020 11:27:33 +0800 Subject: [PATCH] fix cpu nonop fp16 error --- mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc | 5 +++++ mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc b/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc index 92269233bd..c2131a541e 100644 --- a/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc +++ b/mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc @@ -52,6 +52,11 @@ bool CPUDeviceAddress::SyncDeviceToHost(const std::vector & /*shape*/, size bool CPUDeviceAddress::SyncHostToDevice(const std::vector & /*shape*/, size_t size, TypeId type, const void *host_ptr) const { + if (host_ptr == ptr_) { + MS_LOG(DEBUG) << "host_ptr is equal to ptr_, request ignored."; + return true; + } + if (type == kNumberTypeFloat16) { HalfToFloat(ptr_, host_ptr, size / 2); } else if (type == kNumberTypeFloat64) { diff --git a/mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc b/mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc index 401189d592..2ab1c90fd8 100644 --- a/mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc +++ b/mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc @@ -224,7 +224,8 @@ void CPUKernelRuntime::BindInputOutput(const session::KernelGraph *kernel_graph, (void)tensor->data_sync(); } - if (tensor->data_type() == kNumberTypeFloat32 || tensor->data_type() == kNumberTypeInt32) { + if (tensor->data_type() == address->type_id_ || tensor->data_type() == kNumberTypeFloat32 || + tensor->data_type() == kNumberTypeInt32) { address->ptr_ = tensor->data_c(); } else { std::vector data_shape = tensor->shape();