forked from mindspore-Ecosystem/mindspore
!23703 [MSLITE] code const bug
Merge pull request !23703 from ling/base
This commit is contained in:
commit
85b4048577
|
@ -23,10 +23,10 @@ int DoSplit(void *in_data, void **out_data, const int *input_shape, int offset,
|
|||
const SplitParameter *split_param, int data_size) {
|
||||
int8_t *int8_in = (int8_t *)in_data;
|
||||
|
||||
int num_split = split_param->num_split_;
|
||||
int *split_sizes = split_param->split_sizes_;
|
||||
const int num_split = split_param->num_split_;
|
||||
const int *split_sizes = split_param->split_sizes_;
|
||||
const int *strides = split_param->strides_;
|
||||
int split_dim = split_param->split_dim_;
|
||||
const int split_dim = split_param->split_dim_;
|
||||
int in_stride = strides[split_dim];
|
||||
|
||||
int in_stride_bytes = in_stride * data_size;
|
||||
|
|
|
@ -18,15 +18,16 @@
|
|||
#include <string.h>
|
||||
#include "nnacl/errorcode.h"
|
||||
|
||||
int DoSplitWithOverlapParallel(char *in_data, char **out_data, int slice_idx, const SplitWithOverlapParameter *param,
|
||||
const int *start_indices, const int *end_indices) {
|
||||
int DoSplitWithOverlapParallel(const char *in_data, char **out_data, int slice_idx,
|
||||
const SplitWithOverlapParameter *param, const int *start_indices,
|
||||
const int *end_indices) {
|
||||
int start_index = start_indices[slice_idx];
|
||||
int end_index = end_indices[slice_idx];
|
||||
|
||||
int input_stride = param->split_dim_size_ * param->inner_stride_ * param->element_bytes_;
|
||||
int out_stride = (end_index - start_index) * param->inner_stride_ * param->element_bytes_;
|
||||
|
||||
char *src_ptr = in_data + start_index * param->inner_stride_ * param->element_bytes_;
|
||||
const char *src_ptr = in_data + start_index * param->inner_stride_ * param->element_bytes_;
|
||||
char *dst_ptr = out_data[slice_idx];
|
||||
|
||||
for (int i = 0; i < param->outer_total_dim_; i++) {
|
||||
|
|
|
@ -23,8 +23,9 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int DoSplitWithOverlapParallel(char *in_data, char **out_data, int slice_idx, const SplitWithOverlapParameter *param,
|
||||
const int *start_indices, const int *end_indices);
|
||||
int DoSplitWithOverlapParallel(const char *in_data, char **out_data, int slice_idx,
|
||||
const SplitWithOverlapParameter *param, const int *start_indices,
|
||||
const int *end_indices);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -115,12 +115,12 @@ int DoStridedSliceIntFp64Bool(const void *in_data, void *out_data, StridedSliceP
|
|||
}
|
||||
|
||||
int DoStridedSlice(const void *in_data, void *out_data, StridedSliceParameter *param) {
|
||||
if (param->data_type != kDataTypeFloat && param->data_type != kDataTypeFloat16) {
|
||||
return DoStridedSliceIntFp64Bool(in_data, out_data, param);
|
||||
}
|
||||
if (in_data == NULL || out_data == NULL || param == NULL) {
|
||||
return NNACL_NULL_PTR;
|
||||
}
|
||||
if (param->data_type != kDataTypeFloat && param->data_type != kDataTypeFloat16) {
|
||||
return DoStridedSliceIntFp64Bool(in_data, out_data, param);
|
||||
}
|
||||
if (param->num_axes_ > DIMENSION_8D) {
|
||||
return NNACL_PARAM_INVALID;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ int8_t GetInt8Output(float real_out, float output_inverse_scale, int32_t output_
|
|||
}
|
||||
|
||||
void Int8ArgMinMaxDim0(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant_arg, QuantArg *out_quant_arg) {
|
||||
QuantArg *in_quant_arg, const QuantArg *out_quant_arg) {
|
||||
bool out_value = param->out_value_;
|
||||
const float output_inverse_scale = 1.f / out_quant_arg->scale_;
|
||||
float bias = -in_quant_arg->zp_ * in_quant_arg->scale_;
|
||||
|
@ -116,7 +116,7 @@ void Int8ArgMinMaxDim0(const int8_t *input, int8_t *output, const int *in_shape,
|
|||
}
|
||||
|
||||
void Int8ArgMinMaxDim1(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant_arg, QuantArg *out_quant_arg) {
|
||||
QuantArg *in_quant_arg, const QuantArg *out_quant_arg) {
|
||||
bool out_value = param->out_value_;
|
||||
const float output_inverse_scale = 1.f / out_quant_arg->scale_;
|
||||
float bias = -in_quant_arg->zp_ * in_quant_arg->scale_;
|
||||
|
@ -147,7 +147,7 @@ void Int8ArgMinMaxDim1(const int8_t *input, int8_t *output, const int *in_shape,
|
|||
}
|
||||
|
||||
void Int8ArgMinMaxDim2(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant_arg, QuantArg *out_quant_arg) {
|
||||
QuantArg *in_quant_arg, const QuantArg *out_quant_arg) {
|
||||
bool out_value = param->out_value_;
|
||||
const float output_inverse_scale = 1.f / out_quant_arg->scale_;
|
||||
float bias = -in_quant_arg->zp_ * in_quant_arg->scale_;
|
||||
|
@ -182,7 +182,7 @@ void Int8ArgMinMaxDim2(const int8_t *input, int8_t *output, const int *in_shape,
|
|||
}
|
||||
|
||||
void Int8ArgMinMaxDim3(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant_arg, QuantArg *out_quant_arg) {
|
||||
QuantArg *in_quant_arg, const QuantArg *out_quant_arg) {
|
||||
bool out_value = param->out_value_;
|
||||
const float output_inverse_scale = 1.f / out_quant_arg->scale_;
|
||||
float bias = -in_quant_arg->zp_ * in_quant_arg->scale_;
|
||||
|
|
|
@ -26,13 +26,13 @@ extern "C" {
|
|||
void Int8ArgMinMaxQuant(const int8_t *input, int8_t *output, const int *in_shape, const ArgMinMaxParameter *param,
|
||||
const QuantArg *in_quant, const QuantArg *out_quant);
|
||||
void Int8ArgMinMaxDim0(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant, QuantArg *out_quant);
|
||||
QuantArg *in_quant, const QuantArg *out_quant);
|
||||
void Int8ArgMinMaxDim1(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant, QuantArg *out_quant);
|
||||
QuantArg *in_quant, const QuantArg *out_quant);
|
||||
void Int8ArgMinMaxDim2(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant, QuantArg *out_quant);
|
||||
QuantArg *in_quant, const QuantArg *out_quant);
|
||||
void Int8ArgMinMaxDim3(const int8_t *input, int8_t *output, const int *in_shape, ArgMinMaxParameter *param,
|
||||
QuantArg *in_quant, QuantArg *out_quant);
|
||||
QuantArg *in_quant, const QuantArg *out_quant);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
#include "nnacl/concat_parameter.h"
|
||||
#include <string.h>
|
||||
|
||||
void Int8Concat(int8_t **inputs, int8_t *output, ConcatParameter *para, int axis, int64_t real_dst_count, int task_id) {
|
||||
void Int8Concat(int8_t **inputs, int8_t *output, const ConcatParameter *para, int axis, int64_t real_dst_count,
|
||||
int task_id) {
|
||||
float output_scale = para->quant_arg_.out_args_.scale_;
|
||||
const float output_inverse_scale = 1.f / output_scale;
|
||||
int input_num = para->input_num_;
|
||||
|
@ -38,7 +39,7 @@ void Int8Concat(int8_t **inputs, int8_t *output, ConcatParameter *para, int axis
|
|||
for (int i = 0; i < input_num; i++) {
|
||||
const int *input_shape = para->input_shapes_[i];
|
||||
int64_t in_copy_size = input_shape[axis] * after_axis_size;
|
||||
int8_t *input_ptr = inputs[i] + k * in_copy_size;
|
||||
const int8_t *input_ptr = inputs[i] + k * in_copy_size;
|
||||
if (input_quant[i].scale_ == output_scale && input_quant[i].zp_ == output_zp) {
|
||||
memcpy(output, input_ptr, in_copy_size);
|
||||
} else {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void Int8Concat(int8_t **inputs, int8_t *output_ptr, ConcatParameter *para, int axis, int64_t real_dst_count,
|
||||
void Int8Concat(int8_t **inputs, int8_t *output_ptr, const ConcatParameter *para, int axis, int64_t real_dst_count,
|
||||
int task_id);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "nnacl/int8/crop_int8.h"
|
||||
#include <string.h>
|
||||
|
||||
void Int8Crop(const int8_t *input, int8_t *output, int task_id, CropParameter *para) {
|
||||
void Int8Crop(const int8_t *input, int8_t *output, int task_id, const CropParameter *para) {
|
||||
int input_dim = para->input_dim_;
|
||||
switch (input_dim) {
|
||||
case 1:
|
||||
|
@ -36,7 +36,7 @@ void Int8Crop(const int8_t *input, int8_t *output, int task_id, CropParameter *p
|
|||
}
|
||||
}
|
||||
|
||||
void Int8Crop1D(const int8_t *input, int8_t *output, int task_id, CropParameter *para) {
|
||||
void Int8Crop1D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para) {
|
||||
const int out_batch = para->out_shape_[0];
|
||||
const int thread_count = para->thread_count_;
|
||||
int64_t task_id_stride = thread_count > 1 ? UP_DIV(out_batch, thread_count) : out_batch;
|
||||
|
@ -75,7 +75,7 @@ void Int8Crop1D(const int8_t *input, int8_t *output, int task_id, CropParameter
|
|||
return;
|
||||
}
|
||||
|
||||
void Int8Crop2D(const int8_t *input, int8_t *output, int task_id, CropParameter *para) {
|
||||
void Int8Crop2D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para) {
|
||||
const int in_height = para->in_shape_[1];
|
||||
const int out_batch = para->out_shape_[0];
|
||||
const int out_height = para->out_shape_[1];
|
||||
|
@ -118,7 +118,7 @@ void Int8Crop2D(const int8_t *input, int8_t *output, int task_id, CropParameter
|
|||
return;
|
||||
}
|
||||
|
||||
void Int8Crop3D(const int8_t *input, int8_t *output, int task_id, CropParameter *para) {
|
||||
void Int8Crop3D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para) {
|
||||
const int in_height = para->in_shape_[1];
|
||||
const int in_width = para->in_shape_[2];
|
||||
|
||||
|
@ -173,7 +173,7 @@ void Int8Crop3D(const int8_t *input, int8_t *output, int task_id, CropParameter
|
|||
return;
|
||||
}
|
||||
|
||||
void Int8Crop4D(const int8_t *input, int8_t *output, int task_id, CropParameter *para) {
|
||||
void Int8Crop4D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para) {
|
||||
const int in_height = para->in_shape_[1];
|
||||
const int in_width = para->in_shape_[2];
|
||||
const int in_channel = para->in_shape_[3];
|
||||
|
|
|
@ -22,11 +22,11 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void Int8Crop(const int8_t *input, int8_t *output, int task_id, CropParameter *para);
|
||||
void Int8Crop1D(const int8_t *input, int8_t *output, int task_id, CropParameter *para);
|
||||
void Int8Crop2D(const int8_t *input, int8_t *output, int task_id, CropParameter *para);
|
||||
void Int8Crop3D(const int8_t *input, int8_t *output, int task_id, CropParameter *para);
|
||||
void Int8Crop4D(const int8_t *input, int8_t *output, int task_id, CropParameter *para);
|
||||
void Int8Crop(const int8_t *input, int8_t *output, int task_id, const CropParameter *para);
|
||||
void Int8Crop1D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para);
|
||||
void Int8Crop2D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para);
|
||||
void Int8Crop3D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para);
|
||||
void Int8Crop4D(const int8_t *input, int8_t *output, int task_id, const CropParameter *para);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "nnacl/int8/leaky_relu_int8.h"
|
||||
#include "nnacl/errorcode.h"
|
||||
|
||||
int DoLeakReluInt8(int8_t *inputs, int8_t *output_ptr, LeakyReluQuantArg *quant_prelu_parm, int task_id) {
|
||||
int DoLeakReluInt8(const int8_t *inputs, int8_t *output_ptr, LeakyReluQuantArg *quant_prelu_parm, int task_id) {
|
||||
if (quant_prelu_parm == NULL) {
|
||||
return NNACL_NULL_PTR;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int DoLeakReluInt8(int8_t *inputs, int8_t *output_ptr, LeakyReluQuantArg *quant_Prelu_parm, int task_id);
|
||||
int DoLeakReluInt8(const int8_t *inputs, int8_t *output_ptr, LeakyReluQuantArg *quant_Prelu_parm, int task_id);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -102,7 +102,7 @@ void Quantize(const float *input_data, int length, float scale, int zero_point,
|
|||
}
|
||||
|
||||
// dequantize from int8 to float
|
||||
void Dequantize(int8_t *input_data, int length, float scale, int zero_point, float *output_data) {
|
||||
void Dequantize(const int8_t *input_data, int length, float scale, int zero_point, float *output_data) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
output_data[i] = scale * (input_data[i] - zero_point);
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ void CalculateActivationRangeQuantized(bool is_relu, bool is_relu6, int32_t zp,
|
|||
void Quantize(const float *input_data, int length, float scale, int zero_point, int8_t *output_data);
|
||||
|
||||
// dequantize from int8 to float
|
||||
void Dequantize(int8_t *input_data, int length, float scale, int zero_point, float *output_data);
|
||||
void Dequantize(const int8_t *input_data, int length, float scale, int zero_point, float *output_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
#include "nnacl/int8/relux_int8.h"
|
||||
|
||||
void ReluXInt8(const int8_t *src, int length, int8_t *dst, ReluXQuantArg *arg) {
|
||||
void ReluXInt8(const int8_t *src, int length, int8_t *dst, const ReluXQuantArg *arg) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
if (src[i] <= arg->input_arg.zp_) {
|
||||
dst[i] = arg->output_arg.zp_;
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef struct ReluXQuantArg {
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void ReluXInt8(const int8_t *src, int length, int8_t *dst, ReluXQuantArg *arg);
|
||||
void ReluXInt8(const int8_t *src, int length, int8_t *dst, const ReluXQuantArg *arg);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "nnacl/reshape_parameter.h"
|
||||
#include <string.h>
|
||||
|
||||
void Int8Reshape(int8_t *input_ptr, int8_t *output_ptr, int64_t real_dst_count, ReshapeQuantArg para) {
|
||||
void Int8Reshape(const int8_t *input_ptr, int8_t *output_ptr, int64_t real_dst_count, ReshapeQuantArg para) {
|
||||
if (para.in_args_.scale_ == para.out_args_.scale_ && para.in_args_.zp_ == para.out_args_.zp_) {
|
||||
memcpy(output_ptr, input_ptr, real_dst_count);
|
||||
} else {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void Int8Reshape(int8_t *input_ptr, int8_t *output_ptr, int64_t real_dst_count, ReshapeQuantArg para);
|
||||
void Int8Reshape(const int8_t *input_ptr, int8_t *output_ptr, int64_t real_dst_count, ReshapeQuantArg para);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -19,29 +19,29 @@
|
|||
#include <string.h>
|
||||
#include "nnacl/errorcode.h"
|
||||
|
||||
int Int8DoSplit(int8_t *in_data, int8_t **out_data, const int *input_shape, int offset, int num_unit,
|
||||
SplitParameter *param) {
|
||||
int Int8DoSplit(const int8_t *in_data, int8_t **out_data, const int *input_shape, int offset, int num_unit,
|
||||
const SplitParameter *param) {
|
||||
if (in_data == NULL || out_data == NULL) {
|
||||
return NNACL_ERR;
|
||||
}
|
||||
int num_split = param->num_split_;
|
||||
int *split_sizes = param->split_sizes_;
|
||||
int *strides = param->strides_;
|
||||
int split_dim = param->split_dim_;
|
||||
const int num_split = param->num_split_;
|
||||
const int *split_sizes = param->split_sizes_;
|
||||
const int *strides = param->strides_;
|
||||
const int split_dim = param->split_dim_;
|
||||
int in_stride = strides[split_dim];
|
||||
|
||||
int stride_per_split = in_stride * input_shape[split_dim];
|
||||
int split_which = offset % num_split;
|
||||
int split_times = offset / num_split;
|
||||
int8_t *src = in_data + split_times * stride_per_split;
|
||||
const int8_t *src = in_data + split_times * stride_per_split;
|
||||
for (int i = 0; i < split_which; i++) {
|
||||
src += split_sizes[i] * in_stride;
|
||||
}
|
||||
|
||||
QuantArg in_quant_arg = param->quant_arg_.in_args_;
|
||||
const QuantArg in_quant_arg = param->quant_arg_.in_args_;
|
||||
float in_scale = in_quant_arg.scale_;
|
||||
int32_t in_zp = in_quant_arg.zp_;
|
||||
QuantArg *out_quant_arg = param->quant_arg_.out_args_;
|
||||
const QuantArg *out_quant_arg = param->quant_arg_.out_args_;
|
||||
|
||||
for (int i = offset; i < offset + num_unit; i++) {
|
||||
split_which = i % num_split;
|
||||
|
|
|
@ -24,8 +24,8 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
int Int8DoSplit(int8_t *in_data, int8_t **out_data, const int *input_shape, int offset, int num_unit,
|
||||
SplitParameter *split_param);
|
||||
int Int8DoSplit(const int8_t *in_data, int8_t **out_data, const int *input_shape, int offset, int num_unit,
|
||||
const SplitParameter *split_param);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue