From 7129c649dc799d93db27f4346dabda6c9a41e614 Mon Sep 17 00:00:00 2001 From: juncaipeng <13006307475@163.com> Date: Wed, 26 Aug 2020 11:24:08 +0000 Subject: [PATCH] Add fp32 to uint8 cast, test=develop --- lite/kernels/arm/cast_compute.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lite/kernels/arm/cast_compute.cc b/lite/kernels/arm/cast_compute.cc index 4be34df0fb..81416e4ddd 100644 --- a/lite/kernels/arm/cast_compute.cc +++ b/lite/kernels/arm/cast_compute.cc @@ -83,6 +83,11 @@ void CastCompute::Run() { int64_t* out_data = param.Out->mutable_data(); std::transform( x_data_begin, x_data_end, out_data, TransOp); + } else if (param.in_dtype == 5 && param.out_dtype == 20) { // FP32 -> UINT8 + const float* x_data_begin = param.X->data(); + const float* x_data_end = x_data_begin + param.X->numel(); + uint8_t* out_data = param.Out->mutable_data(); + std::transform(x_data_begin, x_data_end, out_data, TransOp); } else { LOG(FATAL) << "other has not been implemented transform with dtype" << param.in_dtype << " X, dtype" << param.out_dtype << " Out"; -- GitLab