Browse Source

fix cpu nonop fp16 error

tags/v0.7.0-beta
kswang 5 years ago
parent
commit
1b1351fa17
2 changed files with 7 additions and 1 deletions
  1. +5
    -0
      mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc
  2. +2
    -1
      mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc

+ 5
- 0
mindspore/ccsrc/runtime/device/cpu/cpu_device_address.cc View File

@@ -52,6 +52,11 @@ bool CPUDeviceAddress::SyncDeviceToHost(const std::vector<int> & /*shape*/, size

bool CPUDeviceAddress::SyncHostToDevice(const std::vector<int> & /*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) {


+ 2
- 1
mindspore/ccsrc/runtime/device/cpu/cpu_kernel_runtime.cc View File

@@ -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<int> data_shape = tensor->shape();


Loading…
Cancel
Save