From 7486f2a20b55452e34810653b6cc094f838d94cf Mon Sep 17 00:00:00 2001 From: ling Date: Tue, 11 Jan 2022 19:33:35 +0800 Subject: [PATCH] [MSLITE] clean fp32 bug --- .../ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/exp_fp32.h | 2 +- .../backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.c | 3 ++- .../backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.h | 3 ++- .../kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.c | 2 +- .../kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.h | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/exp_fp32.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/exp_fp32.h index 37c5f741898..cd31ed0296b 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/exp_fp32.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/exp_fp32.h @@ -172,7 +172,7 @@ static inline void simd_exp32(float src, float *dst) { float decimal = src - integer * param[0]; fi int_exp; int_exp.i = (integer + 127) << 23; - float decimal_exp = + const float decimal_exp = 1.0f + decimal * (1.0f + decimal * (0.5f + decimal * (param[3] + decimal * (param[2] + decimal * param[1])))); *dst = int_exp.f * decimal_exp; } diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.c b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.c index c6b90f80527..c399284419d 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.c +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.c @@ -18,7 +18,8 @@ #include #include "nnacl/errorcode.h" -int DoScatterND(void *output, const void *update, int *output_unit_offsets, ScatterNDParameter *param, int task_id) { +int DoScatterND(void *output, const void *update, int *output_unit_offsets, const ScatterNDParameter *param, + int task_id) { if (param->op_parameter.thread_num_ == 0) { return NNACL_ERR; } diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.h index cb28a964746..63436da296b 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/scatter_nd_fp32.h @@ -29,7 +29,8 @@ typedef struct ScatterNDParameter { #ifdef __cplusplus extern "C" { #endif -int DoScatterND(void *output, const void *update, int *output_unit_offsets, ScatterNDParameter *param, int task_id); +int DoScatterND(void *output, const void *update, int *output_unit_offsets, const ScatterNDParameter *param, + int task_id); #ifdef __cplusplus } #endif diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.c b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.c index 6ee49592a5f..53bac210010 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.c +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.c @@ -16,7 +16,7 @@ #include "nnacl/fp32/sparse_to_dense_fp32.h" #include "nnacl/errorcode.h" -int SparseToDenseSetDefault(float *output, float default_value, SparseToDenseParameter *param, int task_id) { +int SparseToDenseSetDefault(float *output, float default_value, const SparseToDenseParameter *param, int task_id) { if (param->op_parameter_.thread_num_ == 0) { return NNACL_ERR; } diff --git a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.h b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.h index ae8d99a92cc..39b35f4cfd4 100644 --- a/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.h +++ b/mindspore/ccsrc/backend/kernel_compiler/cpu/nnacl/fp32/sparse_to_dense_fp32.h @@ -21,7 +21,7 @@ #ifdef __cplusplus extern "C" { #endif -int SparseToDenseSetDefault(float *output, float default_value, SparseToDenseParameter *param, int task_id); +int SparseToDenseSetDefault(float *output, float default_value, const SparseToDenseParameter *param, int task_id); int SparseToDense(int *indices_vec, const float *sparse_values, float default_value, float *output, SparseToDenseParameter *param, int task_id); #ifdef __cplusplus