From: @zhaozhenlong Reviewed-by: @zhanghaibo5,@zhang_xue_tong Signed-off-by: @zhang_xue_tongtags/v1.1.0
| @@ -16,10 +16,13 @@ | |||||
| #include "nnacl/fp32/reverse_fp32.h" | #include "nnacl/fp32/reverse_fp32.h" | ||||
| #include <string.h> | #include <string.h> | ||||
| #include "nnacl/op_base.h" | |||||
| #include "nnacl/errorcode.h" | #include "nnacl/errorcode.h" | ||||
| #include "nnacl/nnacl_utils.h" | |||||
| int Reverse(const float *input, float *output, size_t elem_size, int *index) { | int Reverse(const float *input, float *output, size_t elem_size, int *index) { | ||||
| for (int i = 0; i < elem_size; i++) { | |||||
| NNACL_ASSERT(index[i] >= 0); | |||||
| } | |||||
| for (int i = 0; i < elem_size; i++) { | for (int i = 0; i < elem_size; i++) { | ||||
| output[index[i]] = input[i]; | output[index[i]] = input[i]; | ||||
| } | } | ||||
| @@ -176,6 +176,11 @@ int DoTransposeFp32(const float *in_data, float *out_data, int *input_shape, con | |||||
| (void)memcpy(out_data, in_data, data_size); | (void)memcpy(out_data, in_data, data_size); | ||||
| return NNACL_OK; | return NNACL_OK; | ||||
| } | } | ||||
| for (int i = 0; i < num_axes; ++i) { | |||||
| if (perm[i] < 0) { | |||||
| return NNACL_PARAM_INVALID; | |||||
| } | |||||
| } | |||||
| if (num_axes == 2) { | if (num_axes == 2) { | ||||
| TransposeDim2Fp32(in_data, out_data, strides, out_strides, perm, output_shape, h_start, h_end); | TransposeDim2Fp32(in_data, out_data, strides, out_strides, perm, output_shape, h_start, h_end); | ||||
| } else if (num_axes == 3) { | } else if (num_axes == 3) { | ||||
| @@ -21,9 +21,18 @@ | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| extern "C" { | extern "C" { | ||||
| #endif | #endif | ||||
| #if defined(__arm__) || defined(__aarch64__) | #if defined(__arm__) || defined(__aarch64__) | ||||
| uint32_t getHwCap(int hwcap_type); | uint32_t getHwCap(int hwcap_type); | ||||
| #endif | #endif | ||||
| #ifdef DEBUG | |||||
| #include <assert.h> | |||||
| #define NNACL_ASSERT(f) assert(f) | |||||
| #else | |||||
| #define NNACL_ASSERT(f) ((void)0) | |||||
| #endif | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #endif | #endif | ||||
| @@ -20,7 +20,7 @@ | |||||
| int DoSqueeze(const float *in_data, float *out_data, size_t data_size) { | int DoSqueeze(const float *in_data, float *out_data, size_t data_size) { | ||||
| if (in_data == NULL || out_data == NULL) { | if (in_data == NULL || out_data == NULL) { | ||||
| return -1; | |||||
| return NNACL_ERR; | |||||
| } | } | ||||
| (void)memcpy(out_data, in_data, data_size); | (void)memcpy(out_data, in_data, data_size); | ||||
| return NNACL_OK; | return NNACL_OK; | ||||
| @@ -28,7 +28,7 @@ int DoSqueeze(const float *in_data, float *out_data, size_t data_size) { | |||||
| int DoSqueezeInt32(int32_t *in_data, int32_t *out_data, size_t data_size) { | int DoSqueezeInt32(int32_t *in_data, int32_t *out_data, size_t data_size) { | ||||
| if (in_data == NULL || out_data == NULL) { | if (in_data == NULL || out_data == NULL) { | ||||
| return -1; | |||||
| return NNACL_ERR; | |||||
| } | } | ||||
| (void)memcpy(out_data, in_data, data_size); | (void)memcpy(out_data, in_data, data_size); | ||||
| return NNACL_OK; | return NNACL_OK; | ||||