Browse Source

[MSLITE] Fix bug of fp16subgraph preprocess.

pull/15518/head
wang_shaocong 4 years ago
parent
commit
1990cfb83c
4 changed files with 7 additions and 4 deletions
  1. +2
    -0
      mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/where_infer.c
  2. +0
    -1
      mindspore/lite/src/runtime/kernel/arm/fp32/where_fp32.cc
  3. +4
    -3
      mindspore/lite/src/sub_graph_kernel.cc
  4. +1
    -0
      mindspore/lite/test/models_onnx_fp16.cfg

+ 2
- 0
mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/infer/where_infer.c View File

@@ -31,6 +31,8 @@ int WhereInferShape(const TensorC *const *inputs, size_t inputs_size, TensorC **


// Need to dynamically allocate at runtime. // Need to dynamically allocate at runtime.
if (inputs_size == 1) { if (inputs_size == 1) {
output->data_type_ = kNumberTypeInt32;
output->format_ = input->format_;
return NNACL_INFER_INVALID; return NNACL_INFER_INVALID;
} }




+ 0
- 1
mindspore/lite/src/runtime/kernel/arm/fp32/where_fp32.cc View File

@@ -89,7 +89,6 @@ int WhereCPUKernel::RunWithSingleInput() {
} }
} }
} }
out_tensors_.at(0)->set_data_type(kNumberTypeInt32);
std::vector<int> output_shape = {true_num, where_param_->rank_}; std::vector<int> output_shape = {true_num, where_param_->rank_};
out_tensors_.at(0)->set_shape(output_shape); out_tensors_.at(0)->set_shape(output_shape);
out_tensors_.at(0)->FreeData(); out_tensors_.at(0)->FreeData();


+ 4
- 3
mindspore/lite/src/sub_graph_kernel.cc View File

@@ -226,12 +226,13 @@ int CpuFp16SubGraph::Float32TensorToFloat16Tensor(lite::Tensor *tensor) {
MS_ASSERT(tensor != nullptr); MS_ASSERT(tensor != nullptr);
auto float32_data = tensor->data_c(); auto float32_data = tensor->data_c();
auto own_data = tensor->own_data(); auto own_data = tensor->own_data();
tensor->set_data_type(TypeId::kNumberTypeFloat16);
if (float32_data == nullptr) { if (float32_data == nullptr) {
MS_LOG(ERROR) << "tensor data is null.";
return lite::RET_NULL_PTR;
// the input data may be nullptr of merge.
MS_LOG(INFO) << "tensor data is null.";
return lite::RET_OK;
} }
tensor->set_data(nullptr); tensor->set_data(nullptr);
tensor->set_data_type(TypeId::kNumberTypeFloat16);
auto ret = tensor->MallocData(); auto ret = tensor->MallocData();
if (RET_OK != ret) { if (RET_OK != ret) {
MS_LOG(ERROR) << "malloc data failed"; MS_LOG(ERROR) << "malloc data failed";


+ 1
- 0
mindspore/lite/test/models_onnx_fp16.cfg View File

@@ -79,3 +79,4 @@ Q_face_recognition.onnx 2
ml_video_edit_enhance_update_tmp.onnx 0.5 ml_video_edit_enhance_update_tmp.onnx 0.5
Q888_face_recognition.onnx 3.5 Q888_face_recognition.onnx 3.5
Q888_iris_detect.onnx 0.5 Q888_iris_detect.onnx 0.5
ssd_mobilenet_v1_10.onnx;1,383,640,3 0.5

Loading…
Cancel
Save