forked from huawei/mindspore2022
!23580 [MS][LITE][CPU] code check
Merge pull request !23580 from liuzhongkai/code_dex1111
This commit is contained in:
commit
295328db82
|
|
@ -18,8 +18,8 @@
|
|||
#include "nnacl/errorcode.h"
|
||||
|
||||
#if defined(ENABLE_ARM) || defined(ENABLE_AVX) || defined(ENABLE_SSE)
|
||||
MS_FLOAT32X4 OptimizedPowerSimd(MS_FLOAT32X4 x, const void *exponent) {
|
||||
int exp = abs((int)(*(float *)exponent));
|
||||
MS_FLOAT32X4 OptimizedPowerSimd(MS_FLOAT32X4 x, const float *exponent) {
|
||||
int exp = abs((int)(*exponent));
|
||||
MS_FLOAT32X4 result = MS_MOVQ_F32(1.0f);
|
||||
while (exp) {
|
||||
if (exp % 2) {
|
||||
|
|
@ -28,15 +28,15 @@ MS_FLOAT32X4 OptimizedPowerSimd(MS_FLOAT32X4 x, const void *exponent) {
|
|||
x = MS_MULQ_F32(x, x);
|
||||
exp = exp / 2;
|
||||
}
|
||||
if (*(float *)exponent >= 0) {
|
||||
if (*exponent >= 0) {
|
||||
return result;
|
||||
}
|
||||
return MS_DIVQ_F32(MS_MOVQ_F32(1), result);
|
||||
}
|
||||
#endif
|
||||
|
||||
float OptimizedPowerScalar(float x, const void *exponent) {
|
||||
int exp = abs((int)(*(float *)exponent));
|
||||
float OptimizedPowerScalar(float x, const float *exponent) {
|
||||
int exp = abs((int)(*exponent));
|
||||
float result = 1;
|
||||
while (exp) {
|
||||
if (exp % 2) {
|
||||
|
|
@ -45,7 +45,7 @@ float OptimizedPowerScalar(float x, const void *exponent) {
|
|||
x *= x;
|
||||
exp = exp / 2;
|
||||
}
|
||||
return *(float *)exponent >= 0 ? result : 1 / result;
|
||||
return *exponent >= 0 ? result : 1 / result;
|
||||
}
|
||||
|
||||
void PowerBroadCast(const float *input, const float *exponent, float *output, int len, float scale, float shift) {
|
||||
|
|
|
|||
|
|
@ -23,23 +23,23 @@
|
|||
#include "nnacl/intrinsics/ms_simd_instructions.h"
|
||||
|
||||
#if defined(ENABLE_ARM) || defined(ENABLE_AVX) || defined(ENABLE_SSE)
|
||||
typedef MS_FLOAT32X4 (*PowerSimdFun)(MS_FLOAT32X4 x, const void *exponent);
|
||||
typedef MS_FLOAT32X4 (*PowerSimdFun)(MS_FLOAT32X4 x, const float *exponent);
|
||||
#endif
|
||||
typedef void (*PowerFun)(const float *, const float *, float *, int, float, float);
|
||||
typedef float (*PowerScalarFun)(float x, const void *exponent);
|
||||
typedef float (*PowerScalarFun)(float x, const float *exponent);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
static inline bool CheckInteger(float f) { return floorf(f) == f; }
|
||||
static inline bool CheckInteger(float f) { return fabsf(f - (int)(f)) < 0.000001; }
|
||||
|
||||
static inline float StdPowerScalar(float x, const void *exponent) { return powf(x, *(float *)exponent); }
|
||||
static inline float StdPowerScalar(float x, const float *exponent) { return powf(x, *exponent); }
|
||||
|
||||
#if defined(ENABLE_ARM) || defined(ENABLE_AVX) || defined(ENABLE_SSE)
|
||||
static inline MS_FLOAT32X4 StdPowerSimd(MS_FLOAT32X4 x, const void *exponent) {
|
||||
static inline MS_FLOAT32X4 StdPowerSimd(MS_FLOAT32X4 x, const float *exponent) {
|
||||
MS_FLOAT32X4 result;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
MS_F32X4_GETI(result, i) = powf(MS_F32X4_GETI(x, i), *(float *)exponent);
|
||||
MS_F32X4_GETI(result, i) = powf(MS_F32X4_GETI(x, i), *exponent);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,8 @@ bool CheckPermTransFormat(const int *perm, const int *perm_transformat, const in
|
|||
return true;
|
||||
}
|
||||
|
||||
int SetOutputShape(int perms_num, const TensorC *input, TensorC *output, int *perm, size_t perm_size, int *out_shape) {
|
||||
int SetOutputShape(int perms_num, const TensorC *input, TensorC *output, const int *perm, size_t perm_size,
|
||||
int *out_shape) {
|
||||
// set output shape
|
||||
size_t in_shape_size = input->shape_size_;
|
||||
output->shape_size_ = in_shape_size;
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ void Deconv4X24AvxKernel(const float *src, const float *weight, float *dst, int
|
|||
_mm256_storeu_ps(dst + C2NUM * stride + C24NUM, res12);
|
||||
}
|
||||
|
||||
void DeconvMatmulAvx(const float *a, const float *b, float *c, int depth, int row, int col, int plane) {
|
||||
void DeconvMatmulAvx(const float *a, const float *b, float *c, int depth, int row, int col, const int plane) {
|
||||
NNACL_CHECK_ZERO_RETURN(plane);
|
||||
int col_num = 0;
|
||||
int col_block = UP_DIV(col / plane, C8NUM);
|
||||
|
|
|
|||
Loading…
Reference in New Issue