!10451 [MSLITE] fix some fp16 subgraph bugs

From: @probiotics_53
Reviewed-by: 
Signed-off-by:
pull/10451/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit 1b2b677b34

@ -21,13 +21,9 @@ namespace lite {
int ArithmeticCompare::InferShape(std::vector<Tensor *> inputs_, std::vector<Tensor *> outputs_) {
auto res = Arithmetic::InferShape(inputs_, outputs_);
if (res == RET_OK) {
auto output = outputs_.front();
output->set_data_type(TypeId::kNumberTypeBool);
return RET_OK;
} else {
return res;
}
}
} // namespace lite
} // namespace mindspore

@ -304,10 +304,12 @@ int PadCPUKernel::CheckPaddings(int *paddings, int length, int *input_shape, int
for (auto i = 0; i < length; ++i) {
int max_valid = input_shape[i] - offset;
if (paddings[i * 2] > max_valid) {
MS_LOG(WARNING) << prefix << "paddings " << paddings[i * 2] << "should be less than " << max_valid + 1;
MS_LOG(ERROR) << prefix << "paddings " << paddings[i * 2] << "should be less than " << max_valid + 1;
return RET_ERROR;
}
if (paddings[i * 2 + 1] > max_valid) {
MS_LOG(WARNING) << prefix << "paddings " << paddings[i * 2 + 1] << "should be less than " << max_valid + 1;
MS_LOG(ERROR) << prefix << "paddings " << paddings[i * 2 + 1] << "should be less than " << max_valid + 1;
return RET_ERROR;
}
}
return RET_OK;

@ -77,5 +77,6 @@ kernel::LiteKernel *CpuShapeFp32KernelCreator(const std::vector<lite::Tensor *>
}
REG_KERNEL(kCPU, kNumberTypeFloat32, PrimitiveType_Shape, CpuShapeFp32KernelCreator)
REG_KERNEL(kCPU, kNumberTypeFloat16, PrimitiveType_Shape, CpuShapeFp32KernelCreator)
REG_KERNEL(kCPU, kNumberTypeInt8, PrimitiveType_Shape, CpuShapeFp32KernelCreator)
} // namespace mindspore::kernel

@ -238,6 +238,9 @@ int CpuFp16SubGraph::PreProcess() {
}
for (auto kernel : this->nodes_) {
for (auto tensor : kernel->out_tensors()) {
if (kernel->Type() == schema::PrimitiveType_Cast) {
continue;
}
if (tensor->data_type() == kNumberTypeFloat32) {
tensor->set_data_type(kNumberTypeFloat16);
}

@ -36,3 +36,4 @@ udnie-9.onnx
adversarial_pruning.onnx
residual_distill_res34_cifar10_bs_1_update.onnx
residual_distill_res50_cifar10_bs_1_update.onnx
encoder.onnx;1,32,83

@ -40,7 +40,11 @@ deeplabv3_257_mv_gpu.tflite 3
multi_person_mobilenet_v1_075_float.tflite 9
#hiai_vad.tflite 20
ide_label_base.tflite 22
#ide_label_retrained.tflite 80
# ide_label_retrained.tflite involves a softmax-like structure whose output channel is 12.
# The values in the first few channels are extremely small and casted into 0 in the fp16 subgraph.
# The next slice operator takes out data from the first 6 channels, which are all zero, causing the error of
# dividing 0 in the following operator.
#ide_label_retrained.tflite
ml_ei_headpose.tflite 3
ml_ei_landmark.tflite 3
mnist.tflite 4

Loading…
Cancel
Save