Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
1ebad864
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
1ebad864
编写于
5月 20, 2020
作者:
D
dingminghui
提交者:
jackzhang235
5月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mlu kernel): fix error caused by cancelling expanding tensor to 4 dims
上级
d397458f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
29 addition
and
15 deletion
+29
-15
lite/kernels/mlu/bridges/concat_op.cc
lite/kernels/mlu/bridges/concat_op.cc
+8
-3
lite/kernels/mlu/bridges/transpose_op.cc
lite/kernels/mlu/bridges/transpose_op.cc
+17
-8
lite/kernels/mlu/io_copy_compute.cc
lite/kernels/mlu/io_copy_compute.cc
+4
-4
未找到文件。
lite/kernels/mlu/bridges/concat_op.cc
浏览文件 @
1ebad864
...
...
@@ -44,9 +44,14 @@ int ConcatConverter(void* ctx, OpLite* op, KernelBase* kernel) {
auto
dims
=
output_dims
.
size
();
int
axis
=
(
param_axis
<
0
)
?
(
param_axis
+
dims
)
:
param_axis
;
CHECK_LE
(
axis
,
4
)
<<
"Unsupport dims in mlu concat"
;
int
nchw_to_nhwc_axis_map
[
4
]
=
{
0
,
3
,
1
,
2
};
int
nhwc_axis
=
nchw_to_nhwc_axis_map
[
axis
];
CHECK_LT
(
axis
,
dims
)
<<
"Unsupport dims in mlu concat"
;
std
::
vector
<
int
>
nchw2nhwc_axis
(
dims
);
nchw2nhwc_axis
[
0
]
=
0
;
if
(
dims
>
1
)
nchw2nhwc_axis
[
1
]
=
dims
-
1
;
for
(
size_t
i
=
2
;
i
<
dims
;
++
i
)
{
nchw2nhwc_axis
[
i
]
=
i
-
1
;
}
int
nhwc_axis
=
nchw2nhwc_axis
[
axis
];
auto
output_tensor
=
graph
->
AddNode
(
out_var_name
,
output_dims
,
CNML_TENSOR
,
CNML_NCHW
,
graph
->
FPType
());
...
...
lite/kernels/mlu/bridges/transpose_op.cc
浏览文件 @
1ebad864
...
...
@@ -22,12 +22,24 @@ namespace subgraph {
namespace
mlu
{
std
::
vector
<
int
>
axis_to_nhwc
(
const
std
::
vector
<
int
>&
axis
)
{
CHECK_EQ
(
axis
.
size
(),
4
)
<<
"Unsupport dim in mlu transpose"
;
std
::
vector
<
int
>
new_axis
(
4
,
0
);
const
std
::
vector
<
int
>
axis_map1
=
{
0
,
2
,
3
,
1
};
const
std
::
vector
<
int
>
axis_map2
=
{
0
,
3
,
1
,
2
};
std
::
vector
<
int
>
new_axis
(
axis
.
size
());
std
::
vector
<
int
>
nhwc2nchw_axis
(
axis
.
size
());
nhwc2nchw_axis
[
0
]
=
0
;
if
(
axis
.
size
()
>
1
)
nhwc2nchw_axis
[
1
]
=
axis
.
size
()
-
1
;
for
(
size_t
i
=
2
;
i
<
axis
.
size
();
++
i
)
{
nhwc2nchw_axis
[
i
]
=
i
-
1
;
}
std
::
vector
<
int
>
nchw2nhwc_axis
(
axis
.
size
());
nchw2nhwc_axis
[
0
]
=
0
;
for
(
size_t
i
=
1
;
i
<
axis
.
size
()
-
1
;
++
i
)
{
nchw2nhwc_axis
[
i
]
=
i
+
1
;
}
if
(
axis
.
size
()
>
1
)
nchw2nhwc_axis
[
axis
.
size
()
-
1
]
=
1
;
for
(
size_t
i
=
0
;
i
<
new_axis
.
size
();
++
i
)
{
new_axis
[
i
]
=
axis_map2
[
axis
[
axis_map1
[
i
]]];
new_axis
[
i
]
=
nhwc2nchw_axis
[
axis
[
nchw2nhwc_axis
[
i
]]];
}
return
new_axis
;
}
...
...
@@ -51,9 +63,6 @@ int TransposeConverter(void* ctx, OpLite* op, KernelBase* kernel) {
auto
output_dims
=
output
->
dims
().
Vectorize
();
auto
axis
=
op_info
->
GetAttr
<
std
::
vector
<
int
>>
(
"axis"
);
while
(
axis
.
size
()
<
4
)
{
axis
.
push_back
(
axis
.
size
());
}
std
::
vector
<
int
>
axis_nhwc
=
axis_to_nhwc
(
axis
);
auto
output_tensor
=
graph
->
AddNode
(
...
...
lite/kernels/mlu/io_copy_compute.cc
浏览文件 @
1ebad864
...
...
@@ -173,14 +173,14 @@ REGISTER_LITE_KERNEL(
kMLU
,
kInt8
,
kNHWC
,
paddle
::
lite
::
kernels
::
mlu
::
IoCopy
MluToHost
Compute
<
PRECISION
(
kInt8
)
>
,
device_to_host
_kInt8
)
paddle
::
lite
::
kernels
::
mlu
::
IoCopy
HostToMlu
Compute
<
PRECISION
(
kInt8
)
>
,
host_to_device_to
_kInt8
)
.
BindInput
(
"Input"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
k
MLU
),
{
LiteType
::
GetTensorTy
(
TARGET
(
k
Host
),
PRECISION
(
kInt8
),
DATALAYOUT
(
kAny
))})
.
BindOutput
(
"Out"
,
{
LiteType
::
GetTensorTy
(
TARGET
(
k
Host
),
{
LiteType
::
GetTensorTy
(
TARGET
(
k
MLU
),
PRECISION
(
kInt8
),
DATALAYOUT
(
kAny
))})
.
Finalize
();
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录