Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
552db8dc
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
552db8dc
编写于
1月 27, 2022
作者:
L
Leo Chen
提交者:
GitHub
1月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[pten] remove concat fluid kernel (#39268)
上级
33e3f5ac
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
3 addition
and
74 deletion
+3
-74
paddle/fluid/operators/concat_op.cc
paddle/fluid/operators/concat_op.cc
+1
-13
paddle/fluid/operators/concat_op.cu.cc
paddle/fluid/operators/concat_op.cu.cc
+1
-12
paddle/fluid/operators/concat_op.h
paddle/fluid/operators/concat_op.h
+0
-48
paddle/fluid/operators/tensor_array_to_tensor_op.cc
paddle/fluid/operators/tensor_array_to_tensor_op.cc
+1
-1
未找到文件。
paddle/fluid/operators/concat_op.cc
浏览文件 @
552db8dc
...
...
@@ -253,19 +253,7 @@ REGISTER_OPERATOR(concat_grad, ops::ConcatOpGrad,
ops
::
ConcatDoubleGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
ConcatDoubleGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
ops
::
ConcatOpGradNoNeedBufferVarInferer
);
REGISTER_OP_CPU_KERNEL
(
concat
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
float
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
bool
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int64_t
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
float16
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
int
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
uint8_t
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
complex
<
float
>>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CPUDeviceContext
,
paddle
::
platform
::
complex
<
double
>>
);
REGISTER_OP_CPU_KERNEL
(
concat_grad
,
ops
::
ConcatGradKernel
<
paddle
::
platform
::
CPUDeviceContext
,
double
>
,
...
...
paddle/fluid/operators/concat_op.cu.cc
浏览文件 @
552db8dc
...
...
@@ -18,18 +18,7 @@ limitations under the License. */
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
REGISTER_OP_CUDA_KERNEL
(
concat
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
float
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
bool
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int64_t
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
int
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
uint8_t
>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
complex
<
float
>>
,
ops
::
ConcatKernel
<
paddle
::
platform
::
CUDADeviceContext
,
plat
::
complex
<
double
>>
);
REGISTER_OP_CUDA_KERNEL
(
concat_grad
,
ops
::
ConcatGradKernel
<
paddle
::
platform
::
CUDADeviceContext
,
double
>
,
...
...
paddle/fluid/operators/concat_op.h
浏览文件 @
552db8dc
...
...
@@ -39,54 +39,6 @@ static inline int64_t ComputeAxis(int64_t axis, int64_t rank) {
}
return
axis
>
0
?
axis
:
0
;
}
template
<
typename
DeviceContext
,
typename
T
>
class
ConcatKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
void
Compute
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
ins
=
ctx
.
MultiInput
<
framework
::
LoDTensor
>
(
"X"
);
framework
::
LoDTensor
*
out
=
ctx
.
Output
<
framework
::
LoDTensor
>
(
"Out"
);
PADDLE_ENFORCE_NOT_NULL
(
ins
[
0
],
platform
::
errors
::
NotFound
(
"The first input tensor is not initalized."
));
auto
axis
=
ctx
.
Attr
<
int
>
(
"axis"
);
bool
need_resize_out_dims
=
false
;
if
(
ctx
.
HasInput
(
"AxisTensor"
))
{
auto
*
axis_tensor
=
ctx
.
Input
<
framework
::
Tensor
>
(
"AxisTensor"
);
axis
=
GetDataFromTensor
<
int
>
(
axis_tensor
)[
0
];
need_resize_out_dims
=
true
;
}
axis
=
ComputeAxis
(
static_cast
<
int64_t
>
(
axis
),
static_cast
<
int64_t
>
(
ins
[
0
]
->
dims
().
size
()));
if
(
need_resize_out_dims
)
{
const
size_t
n
=
ins
.
size
();
std
::
vector
<
framework
::
DDim
>
ins_dims
(
n
);
for
(
size_t
i
=
0
;
i
<
n
;
i
++
)
{
ins_dims
[
i
]
=
ins
[
i
]
->
dims
();
}
framework
::
DDim
out_dims
=
pten
::
funcs
::
ComputeAndCheckShape
(
true
,
ins_dims
,
axis
);
out
->
Resize
(
out_dims
);
}
auto
place
=
ctx
.
GetPlace
();
out
->
mutable_data
<
T
>
(
place
);
// call new kernel
auto
&
dev_ctx
=
ctx
.
device_context
<
DeviceContext
>
();
std
::
vector
<
pten
::
DenseTensor
>
pt_ins
;
for
(
auto
&
in
:
ins
)
{
pt_ins
.
push_back
(
*
in
);
}
pten
::
ConcatKernel
<
T
>
(
static_cast
<
const
typename
paddle
::
framework
::
ConvertToPtenContext
<
DeviceContext
>::
TYPE
&>
(
dev_ctx
),
pt_ins
,
axis
,
out
);
}
};
template
<
typename
DeviceContext
,
typename
T
>
class
ConcatGradKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
...
...
paddle/fluid/operators/tensor_array_to_tensor_op.cc
浏览文件 @
552db8dc
...
...
@@ -299,7 +299,7 @@ class TensorArrayToTensorGradOpMaker : public framework::SingleGradOpMaker<T> {
}
// namespace operators
}
// namespace paddle
USE_OP
(
concat
);
USE_OP
_ITSELF
(
concat
);
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录