Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
2b895074
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b895074
编写于
8月 13, 2020
作者:
Z
zhaozhenlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pad int8 add multi thread
上级
1b63c76c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
11 deletion
+33
-11
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc
+22
-5
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
+3
-0
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.c
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.c
+5
-4
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.h
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.h
+2
-2
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/pad_int8_tests.cc
...ite/test/ut/src/runtime/kernel/arm/int8/pad_int8_tests.cc
+1
-0
未找到文件。
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.cc
浏览文件 @
2b895074
...
...
@@ -111,18 +111,35 @@ int PadInt8CPUKernel::Init() {
return
RET_OK
;
}
int
PadInt8CPUKernel
::
RunImpl
(
int
task_id
)
{
return
PadConstant4D
(
in_data_
,
out_data_
,
in_dims_
,
out_dims_
,
pad_param_
->
paddings_
,
task_id
,
context_
->
thread_num_
);
}
int
PadInt8Impl
(
int
task_id
,
LiteParallelGroupEnv
*
penv
,
void
*
cdata
)
{
auto
resize
=
reinterpret_cast
<
PadInt8CPUKernel
*>
(
cdata
);
auto
error_code
=
resize
->
RunImpl
(
task_id
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Resize Run error task_id["
<<
task_id
<<
"] error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
}
return
RET_OK
;
}
int
PadInt8CPUKernel
::
Run
()
{
auto
ret
=
Prepare
();
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Prepare failed."
;
return
RET_ERROR
;
}
in
t8_t
*
in_data
=
reinterpret_cast
<
int8_t
*>
(
in_tensors_
[
0
]
->
Data
());
int8_t
*
out_data
=
reinterpret_cast
<
int8_t
*>
(
out_tensors_
[
0
]
->
Data
());
in
_data_
=
reinterpret_cast
<
int8_t
*>
(
in_tensors_
[
0
]
->
Data
());
out_data_
=
reinterpret_cast
<
int8_t
*>
(
out_tensors_
[
0
]
->
Data
());
memset
(
out_data
,
pad_param_
->
pad_quant_arg_
.
constant_value_
[
0
],
out_tensors_
[
0
]
->
ElementsNum
()
*
sizeof
(
int8_t
));
PadConstant4D
(
in_data
,
out_data
,
in_dims_
,
out_dims_
,
pad_param_
->
paddings_
);
memset
(
out_data_
,
pad_param_
->
pad_quant_arg_
.
constant_value_
[
0
],
out_tensors_
[
0
]
->
ElementsNum
()
*
sizeof
(
int8_t
));
int
error_code
=
LiteBackendParallelLaunch
(
PadInt8Impl
,
this
,
context_
->
thread_num_
);
if
(
error_code
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Resize run error, error_code["
<<
error_code
<<
"]"
;
return
RET_ERROR
;
}
return
RET_OK
;
}
}
// namespace mindspore::kernel
mindspore/lite/src/runtime/kernel/arm/int8/pad_int8.h
浏览文件 @
2b895074
...
...
@@ -38,6 +38,7 @@ class PadInt8CPUKernel : public LiteKernel {
int
Init
()
override
;
int
ReSize
()
override
;
int
Run
()
override
;
int
RunImpl
(
int
task_id
);
private:
int
SetQuantParam
();
...
...
@@ -46,6 +47,8 @@ class PadInt8CPUKernel : public LiteKernel {
private:
PadParameter
*
pad_param_
;
int8_t
*
in_data_
;
int8_t
*
out_data_
;
int
in_dims_
[
DEFAULT_PAD_NDIMS
];
int
out_dims_
[
DEFAULT_PAD_NDIMS
];
};
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.c
浏览文件 @
2b895074
...
...
@@ -16,12 +16,13 @@
#include "nnacl/int8/pad.h"
#include "nnacl/common_func.h"
#include "nnacl/errorcode.h"
void
PadConstant4D
(
const
int8_t
*
in_data
,
int8_t
*
out_data
,
const
int32_t
*
in_dims
,
const
int32_t
*
out_dims
,
const
int32_t
*
paddings
)
{
int
PadConstant4D
(
const
int8_t
*
in_data
,
int8_t
*
out_data
,
const
int32_t
*
in_dims
,
const
int32_t
*
out_dims
,
const
int32_t
*
paddings
,
const
int
tid
,
const
int
thread_num
)
{
int32_t
copy_size
=
in_dims
[
3
];
for
(
int
n
=
0
;
n
<
in_dims
[
0
];
n
++
)
{
for
(
int
h
=
0
;
h
<
in_dims
[
1
];
h
++
)
{
for
(
int
h
=
tid
;
h
<
in_dims
[
1
];
h
+=
thread_num
)
{
for
(
int
w
=
0
;
w
<
in_dims
[
2
];
w
++
)
{
const
int8_t
*
in
=
in_data
+
offset
(
in_dims
,
n
,
h
,
w
,
0
);
int8_t
*
out
=
out_data
+
offset
(
out_dims
,
n
+
paddings
[
0
],
h
+
paddings
[
2
],
w
+
paddings
[
4
],
paddings
[
6
]);
...
...
@@ -29,5 +30,5 @@ void PadConstant4D(const int8_t *in_data, int8_t *out_data, const int32_t *in_di
}
}
}
return
;
return
NNACL_OK
;
}
mindspore/lite/src/runtime/kernel/arm/nnacl/int8/pad.h
浏览文件 @
2b895074
...
...
@@ -24,8 +24,8 @@
#ifdef __cplusplus
extern
"C"
{
#endif
void
PadConstant4D
(
const
int8_t
*
in_data
,
int8_t
*
out_data
,
const
int32_t
*
in_dims
,
const
int32_t
*
out_dims
,
const
int32_t
*
paddings
);
int
PadConstant4D
(
const
int8_t
*
in_data
,
int8_t
*
out_data
,
const
int32_t
*
in_dims
,
const
int32_t
*
out_dims
,
const
int32_t
*
paddings
,
const
int
tid
,
const
int
thread_num
);
#ifdef __cplusplus
}
#endif
...
...
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/pad_int8_tests.cc
浏览文件 @
2b895074
...
...
@@ -183,6 +183,7 @@ TEST_F(TestPadInt8, PadInt8TestInit4) {
std
::
vector
<
lite
::
tensor
::
Tensor
*>
outputs_
;
auto
pad_param
=
new
PadParameter
();
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread_num_
=
2
;
int8_t
*
correct
;
int
total_size
=
PadInt8TestInit2
(
&
inputs_
,
&
outputs_
,
pad_param
,
&
correct
);
kernel
::
PadInt8CPUKernel
*
pad
=
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录