!3466 fix cpu nonop net fp16 error

Merge pull request !3466 from kisnwang/r0.6-fix-cpu-nonop-fp16-error
This commit is contained in:
mindspore-ci-bot 2020-07-25 16:56:49 +08:00 committed by Gitee
commit ac564a9e86
2 changed files with 7 additions and 1 deletions

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) {

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();