!28737 [MSLITE][GPU] mindspore lite frame, gpu subgraph data_type set error bugfix

Merge pull request !28737 from Greatpan/to_format_bugfix
This commit is contained in:
i-robot 2022-01-10 07:52:22 +00:00 committed by Gitee
commit e6c8f2ad5e
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 12 additions and 6 deletions

View File

@ -72,6 +72,15 @@ bool OfflineIsolated(const std::vector<kernel::LiteKernel *> &kernels, const ker
return true; return true;
} }
TypeId GetSubgraphInTensorDataType(const kernel::LiteKernel *kernel, const lite::Tensor *tensor) {
if (kernel->subgraph_type() != kernel::kGpuFp16SubGraph || tensor->IsGraphInput() || tensor->IsGraphOutput()) {
if (tensor->data_type() == kNumberTypeFloat16 || tensor->data_type() == kNumberTypeFloat32) {
return kernel->desc().data_type;
}
}
return tensor->data_type();
}
int LiteOpActor::PreInit(std::vector<std::shared_ptr<LiteOpActor>> *actors, int LiteOpActor::PreInit(std::vector<std::shared_ptr<LiteOpActor>> *actors,
std::unordered_map<Tensor *, Tensor *> *input_map) { std::unordered_map<Tensor *, Tensor *> *input_map) {
return IsolateInputData(actors, input_map); return IsolateInputData(actors, input_map);
@ -105,11 +114,7 @@ int LiteOpActor::IsolateInputData(std::vector<std::shared_ptr<LiteOpActor>> *act
continue; continue;
} }
TypeId new_data_type = old_tensor->data_type(); TypeId new_data_type = GetSubgraphInTensorDataType(kernel_, old_tensor);
if (old_tensor->data_type() == kNumberTypeFloat16 || old_tensor->data_type() == kNumberTypeFloat32) {
new_data_type = kernel_->desc().data_type;
}
Tensor *new_tensor = new Tensor(new_data_type, old_tensor->shape(), old_tensor->format(), old_tensor->category()); Tensor *new_tensor = new Tensor(new_data_type, old_tensor->shape(), old_tensor->format(), old_tensor->category());
if (new_tensor == nullptr) { if (new_tensor == nullptr) {
MS_LOG(ERROR) << "new Tensor failed."; MS_LOG(ERROR) << "new Tensor failed.";

View File

@ -91,7 +91,7 @@ Q_crnn_ori_v2_405001_notrans_nopre_pb2tflite.tflite 33
Q_crnn_screen_slim400w_more_20w_pb2tflite.tflite 31 Q_crnn_screen_slim400w_more_20w_pb2tflite.tflite 31
Q_focusocr_cn_recog.tflite 24 Q_focusocr_cn_recog.tflite 24
Q_focusocr_jk_recog.tflite 14 Q_focusocr_jk_recog.tflite 14
matmul.pb matmul.pb
add_uint8.tflite;2 add_uint8.tflite;2
mtk_face_features_v3.onnx 7 mtk_face_features_v3.onnx 7
hdc_Face_Landmark5_MTI_Aesthetic.onnx hdc_Face_Landmark5_MTI_Aesthetic.onnx
@ -233,6 +233,7 @@ ml_ei_headpose_pb2tflite.tflite;3:input_1,batch_normalization_8/batchnorm_1/add,
#lite-model_mobilebert_1_metadata_1.tflite's precision deteriorates in P50 #lite-model_mobilebert_1_metadata_1.tflite's precision deteriorates in P50
lite-model_mobilebert_1_metadata_1.tflite;3:input_ids,input_mask,segment_ids 23 lite-model_mobilebert_1_metadata_1.tflite;3:input_ids,input_mask,segment_ids 23
coco_ssd_mobilenet_v1_1.0.tflite coco_ssd_mobilenet_v1_1.0.tflite
bolt_segment.pb 4
glasses glasses
hat hat
isface isface