Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
a14dc688
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a14dc688
编写于
1月 21, 2022
作者:
C
chentianyu03
提交者:
GitHub
1月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pten] fix test concat dev api build failed (#39117)
* fix test concat dev api build failed * fix conflict * fix conflict
上级
a0f586bc
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
17 addition
and
14 deletion
+17
-14
paddle/fluid/operators/concat_op.h
paddle/fluid/operators/concat_op.h
+4
-1
paddle/pten/kernels/cpu/concat_kernel.cc
paddle/pten/kernels/cpu/concat_kernel.cc
+1
-1
paddle/pten/kernels/gpu/concat_kernel.cu
paddle/pten/kernels/gpu/concat_kernel.cu
+1
-1
paddle/pten/tests/api/test_concat_api.cc
paddle/pten/tests/api/test_concat_api.cc
+4
-2
paddle/pten/tests/kernels/test_concat_dev_api.cc
paddle/pten/tests/kernels/test_concat_dev_api.cc
+7
-9
未找到文件。
paddle/fluid/operators/concat_op.h
浏览文件 @
a14dc688
...
...
@@ -80,7 +80,10 @@ class ConcatKernel : public framework::OpKernel<T> {
pt_ins
.
push_back
(
*
in
);
}
pten
::
ConcatKernel
<
T
>
(
dev_ctx
,
pt_ins
,
axis
,
out
);
pten
::
ConcatKernel
<
T
>
(
static_cast
<
const
typename
paddle
::
framework
::
ConvertToPtenContext
<
DeviceContext
>::
TYPE
&>
(
dev_ctx
),
pt_ins
,
axis
,
out
);
}
};
...
...
paddle/pten/kernels/cpu/concat_kernel.cc
浏览文件 @
a14dc688
...
...
@@ -43,7 +43,7 @@ void ConcatKernel(const Context& dev_ctx,
pten
::
DDim
out_dims
=
pten
::
funcs
::
ComputeAndCheckShape
(
true
,
x_dims
,
axis
);
out
->
Resize
(
out_dims
);
out
->
mutable_data
<
T
>
();
out
->
mutable_data
<
T
>
(
dev_ctx
.
GetPlace
()
);
// If axis is 0, the lod of the output is not the same as inputs.
if
(
axis
==
0
&&
x
[
0
].
lod
().
size
()
>
0
)
{
...
...
paddle/pten/kernels/gpu/concat_kernel.cu
浏览文件 @
a14dc688
...
...
@@ -43,7 +43,7 @@ void ConcatKernel(const Context& dev_ctx,
pten
::
DDim
out_dims
=
pten
::
funcs
::
ComputeAndCheckShape
(
true
,
x_dims
,
axis
);
out
->
Resize
(
out_dims
);
out
->
mutable_data
<
T
>
();
out
->
mutable_data
<
T
>
(
dev_ctx
.
GetPlace
()
);
// If axis is 0, the lod of the output is not the same as inputs.
if
(
axis
==
0
&&
x
[
0
].
lod
().
size
()
>
0
)
{
...
...
paddle/pten/tests/api/test_concat_api.cc
浏览文件 @
a14dc688
...
...
@@ -37,14 +37,16 @@ TEST(API, concat) {
pten
::
DenseTensorMeta
(
pten
::
DataType
::
FLOAT32
,
framework
::
make_ddim
({
3
,
10
}),
pten
::
DataLayout
::
NCHW
));
auto
*
dense_x_data
=
dense_x
->
mutable_data
<
float
>
();
auto
*
dense_x_data
=
dense_x
->
mutable_data
<
float
>
(
paddle
::
platform
::
CPUPlace
());
auto
dense_y
=
std
::
make_shared
<
pten
::
DenseTensor
>
(
alloc
.
get
(),
pten
::
DenseTensorMeta
(
pten
::
DataType
::
FLOAT32
,
framework
::
make_ddim
({
3
,
10
}),
pten
::
DataLayout
::
NCHW
));
auto
*
dense_y_data
=
dense_y
->
mutable_data
<
float
>
();
auto
*
dense_y_data
=
dense_y
->
mutable_data
<
float
>
(
paddle
::
platform
::
CPUPlace
());
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
10
;
++
j
)
{
...
...
paddle/pten/tests/kernels/test_concat_dev_api.cc
浏览文件 @
a14dc688
...
...
@@ -25,7 +25,7 @@ namespace pten {
namespace
tests
{
namespace
framework
=
paddle
::
framework
;
using
DDim
=
p
addle
::
framework
::
DDim
;
using
DDim
=
p
ten
::
framework
::
DDim
;
TEST
(
DEV_API
,
concat
)
{
// 1. create tensor
...
...
@@ -35,13 +35,15 @@ TEST(DEV_API, concat) {
pten
::
DenseTensorMeta
(
pten
::
DataType
::
FLOAT32
,
framework
::
make_ddim
({
3
,
10
}),
pten
::
DataLayout
::
NCHW
));
auto
*
dense_x_data
=
dense_x
.
mutable_data
<
float
>
();
auto
*
dense_x_data
=
dense_x
.
mutable_data
<
float
>
(
paddle
::
platform
::
CPUPlace
());
pten
::
DenseTensor
dense_y
(
alloc
.
get
(),
pten
::
DenseTensorMeta
(
pten
::
DataType
::
FLOAT32
,
framework
::
make_ddim
({
3
,
10
}),
pten
::
DataLayout
::
NCHW
));
auto
*
dense_y_data
=
dense_y
.
mutable_data
<
float
>
();
auto
*
dense_y_data
=
dense_y
.
mutable_data
<
float
>
(
paddle
::
platform
::
CPUPlace
());
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
10
;
++
j
)
{
...
...
@@ -50,15 +52,11 @@ TEST(DEV_API, concat) {
}
}
paddle
::
platform
::
DeviceContextPool
&
pool
=
paddle
::
platform
::
DeviceContextPool
::
Instance
();
auto
*
dev_ctx
=
pool
.
Get
(
paddle
::
platform
::
CPUPlace
());
std
::
vector
<
pten
::
DenseTensor
>
inputs
=
{
dense_x
,
dense_y
};
// 2. test API
auto
out
=
pten
::
Concat
<
float
>
(
*
(
static_cast
<
paddle
::
platform
::
CPUDeviceContext
*>
(
dev_ctx
))
,
inputs
,
0
);
pten
::
CPUContext
dev_ctx
;
auto
out
=
pten
::
Concat
<
float
>
(
dev_ctx
,
inputs
,
0
);
// 3. check result
ASSERT_EQ
(
out
.
dims
().
size
(),
2
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录