Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
21502810
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
21502810
编写于
8月 18, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 18, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4635 Fix aborted bug of softmax op
Merge pull request !4635 from wangminggui/master
上级
f6d086d7
432f3432
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
17 addition
and
10 deletion
+17
-10
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc
+6
-5
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.h
+2
-2
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.c
...ore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.c
+3
-2
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.h
...ore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/nnacl/quantization/quantize.h
...lite/src/runtime/kernel/arm/nnacl/quantization/quantize.h
+5
-0
未找到文件。
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.cc
浏览文件 @
21502810
...
...
@@ -15,6 +15,7 @@
*/
#include "src/runtime/kernel/arm/int8/softmax_int8.h"
#include <limits>
#include "src/runtime/kernel/arm/nnacl/int8/softmax_int8.h"
#include "schema/model_generated.h"
#include "src/runtime/runtime_api.h"
...
...
@@ -44,6 +45,8 @@ int SoftmaxInt8CPUKernel::Init() {
auto
out_quant_args
=
out_tensor
->
GetQuantParams
();
quant_params_
.
out_quant_arg_
.
scale_
=
out_quant_args
.
front
().
scale
;
quant_params_
.
out_quant_arg_
.
zp_
=
out_quant_args
.
front
().
zeroPoint
;
quant_params_
.
output_activation_min_
=
std
::
numeric_limits
<
int8_t
>::
min
();
quant_params_
.
output_activation_max_
=
std
::
numeric_limits
<
int8_t
>::
max
();
if
(
!
InferShapeDone
())
{
return
RET_OK
;
...
...
@@ -95,12 +98,10 @@ int SoftmaxInt8CPUKernel::DoSoftmax(int task_id) {
int
stride
=
UP_DIV
(
outter_size
,
thread_count_
);
int
count
=
MSMIN
(
stride
,
outter_size
-
stride
*
task_id
);
int
stride_size
=
stride
*
task_id
*
inner_size
;
input_ptr
+=
stride
*
task_id
*
inner_size
;
output_ptr
+=
stride
*
task_id
*
inner_size
;
exp_data_
+=
stride
*
task_id
*
inner_size
;
auto
error_code
=
Int8Softmax
(
input_ptr
,
output_ptr
,
count
,
exp_data_
,
sum_data_
,
quant_params_
,
softmax_param_
);
auto
error_code
=
SoftmaxInt8
(
input_ptr
+
stride_size
,
output_ptr
+
stride_size
,
count
,
exp_data_
+
stride_size
,
sum_data_
,
quant_params_
,
softmax_param_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"DoSoftmax error task_id["
<<
task_id
<<
"] error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/int8/softmax_int8.h
浏览文件 @
21502810
...
...
@@ -37,8 +37,8 @@ class SoftmaxInt8CPUKernel : public SoftmaxBaseCPUKernel {
private:
void
FreeTmpBuffer
();
float
*
sum_data_
;
float
*
exp_data_
;
float
*
sum_data_
=
nullptr
;
float
*
exp_data_
=
nullptr
;
SoftmaxQuantArg
quant_params_
;
};
}
// namespace mindspore::kernel
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.c
浏览文件 @
21502810
...
...
@@ -17,7 +17,7 @@
#include "nnacl/int8/softmax_int8.h"
#include <math.h>
int
Int8Softmax
(
const
int8_t
*
input_ptr
,
int8_t
*
output_ptr
,
int
count
,
float
*
exp_data
,
float
*
sum_data
,
int
SoftmaxInt8
(
const
int8_t
*
input_ptr
,
int8_t
*
output_ptr
,
int
count
,
float
*
exp_data
,
float
*
sum_data
,
SoftmaxQuantArg
quant_param
,
SoftmaxParameter
*
parameter
)
{
int32_t
axis
=
parameter
->
axis_
;
int
n_dim
=
parameter
->
n_dim_
;
...
...
@@ -48,7 +48,8 @@ int Int8Softmax(const int8_t *input_ptr, int8_t *output_ptr, int count, float *e
int
inner_offset
=
axis_offset
+
i
;
float
real_output
=
exp_data
[
inner_offset
]
/
sum_data
[
i
];
int32_t
output_scaled
=
round
(
real_output
/
output_scale
)
+
output_zp
;
output_ptr
[
inner_offset
]
=
MSMAX
(
CHAR_MIN
,
MSMIN
(
CHAR_MAX
,
output_scaled
));
output_ptr
[
inner_offset
]
=
MSMAX
(
quant_param
.
output_activation_min_
,
MSMIN
(
quant_param
.
output_activation_max_
,
output_scaled
));
}
}
}
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/softmax_int8.h
浏览文件 @
21502810
...
...
@@ -24,7 +24,7 @@
#ifdef __cplusplus
extern
"C"
{
#endif
int
Int8Softmax
(
const
int8_t
*
input_ptr
,
int8_t
*
output_ptr
,
int
count
,
float
*
exp_data
,
float
*
sum_data
,
int
SoftmaxInt8
(
const
int8_t
*
input_ptr
,
int8_t
*
output_ptr
,
int
count
,
float
*
exp_data
,
float
*
sum_data
,
SoftmaxQuantArg
quant_param
,
SoftmaxParameter
*
parameter
);
#ifdef __cplusplus
}
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/quantization/quantize.h
浏览文件 @
21502810
...
...
@@ -169,6 +169,11 @@ typedef struct SplitQuantArg {
typedef
struct
SoftmaxQuantArg
{
QuantArg
in_quant_args_
;
QuantArg
out_quant_arg_
;
int
output_activation_min_
;
int
output_activation_max_
;
int
output_multiplier_
;
int
shift_left_
;
int
shift_right_
;
}
SoftmaxQuantArg
;
typedef
struct
ReshapeQuantArg
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录