Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
bb38b6aa
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
bb38b6aa
编写于
12月 22, 2021
作者:
C
Chen Weihang
提交者:
GitHub
12月 23, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move sign kernel impl (#38363)
上级
0a4ffbc7
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
114 addition
and
24 deletion
+114
-24
paddle/fluid/operators/sign_op.h
paddle/fluid/operators/sign_op.h
+1
-2
paddle/pten/api/lib/kernel_declare.h
paddle/pten/api/lib/kernel_declare.h
+2
-2
paddle/pten/kernels/cpu/math.cc
paddle/pten/kernels/cpu/math.cc
+0
-7
paddle/pten/kernels/cpu/math.h
paddle/pten/kernels/cpu/math.h
+0
-3
paddle/pten/kernels/cpu/sign_kernel.cc
paddle/pten/kernels/cpu/sign_kernel.cc
+24
-0
paddle/pten/kernels/gpu/math.cu
paddle/pten/kernels/gpu/math.cu
+0
-7
paddle/pten/kernels/gpu/math.h
paddle/pten/kernels/gpu/math.h
+0
-3
paddle/pten/kernels/gpu/sign_kernel.cu
paddle/pten/kernels/gpu/sign_kernel.cu
+27
-0
paddle/pten/kernels/impl/sign_kernel_impl.h
paddle/pten/kernels/impl/sign_kernel_impl.h
+36
-0
paddle/pten/kernels/sign_kernel.h
paddle/pten/kernels/sign_kernel.h
+24
-0
未找到文件。
paddle/fluid/operators/sign_op.h
浏览文件 @
bb38b6aa
...
...
@@ -19,9 +19,8 @@ limitations under the License. */
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/fluid/operators/eigen/eigen_function.h"
// only can include the headers in paddle/pten/api dirs
#include "paddle/pten/include/core.h"
#include "paddle/pten/
include/math
.h"
#include "paddle/pten/
kernels/sign_kernel
.h"
namespace
paddle
{
namespace
operators
{
...
...
paddle/pten/api/lib/kernel_declare.h
浏览文件 @
bb38b6aa
...
...
@@ -22,13 +22,13 @@ limitations under the License. */
PT_DECLARE_KERNEL
(
matmul
,
CPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
cast
,
CPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
sig
n
,
CPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
mea
n
,
CPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
conj
,
CPU
,
ALL_LAYOUT
);
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
PT_DECLARE_KERNEL
(
matmul
,
GPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
cast
,
GPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
sig
n
,
GPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
mea
n
,
GPU
,
ALL_LAYOUT
);
PT_DECLARE_KERNEL
(
conj
,
GPU
,
ALL_LAYOUT
);
#endif
...
...
paddle/pten/kernels/cpu/math.cc
浏览文件 @
bb38b6aa
...
...
@@ -17,7 +17,6 @@
#include "paddle/pten/api/ext/dispatch.h"
#include "paddle/pten/kernels/hybird/cpu/elementwise.h"
#include "paddle/pten/kernels/hybird/eigen/reduce.h"
#include "paddle/pten/kernels/hybird/eigen/sign.h"
#include "paddle/pten/kernels/hybird/general/elementwise_functor.h"
#include "paddle/pten/kernels/hybird/general/reduce_impl.h"
...
...
@@ -28,11 +27,6 @@
namespace
pten
{
template
<
typename
T
>
void
Sign
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
eigen
::
Sign
<
CPUContext
,
T
>
(
dev_ctx
,
x
,
out
);
}
template
<
typename
T
>
void
Mean
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
@@ -97,7 +91,6 @@ using complex128 = ::paddle::platform::complex<double>;
// NOTE(chenweihang): using bfloat16 will cause redefine with xpu bfloat16
// using bfloat16 = ::paddle::platform::bfloat16;
PT_REGISTER_KERNEL
(
sign
,
CPU
,
ALL_LAYOUT
,
pten
::
Sign
,
float
,
double
)
{}
PT_REGISTER_KERNEL
(
mean
,
CPU
,
ALL_LAYOUT
,
pten
::
Mean
,
float
,
double
,
bool
)
{}
PT_REGISTER_KERNEL
(
add
,
CPU
,
...
...
paddle/pten/kernels/cpu/math.h
浏览文件 @
bb38b6aa
...
...
@@ -21,9 +21,6 @@ limitations under the License. */
namespace
pten
{
template
<
typename
T
>
void
Sign
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
);
template
<
typename
T
>
void
Mean
(
const
CPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
paddle/pten/kernels/cpu/sign_kernel.cc
0 → 100644
浏览文件 @
bb38b6aa
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/pten/kernels/sign_kernel.h"
#include "paddle/pten/kernels/impl/sign_kernel_impl.h"
#include "paddle/pten/backends/cpu/cpu_context.h"
#include "paddle/pten/core/kernel_registry.h"
// See Note [ Why still include the fluid headers? ]
#include "paddle/fluid/platform/bfloat16.h"
PT_REGISTER_CTX_KERNEL
(
sign
,
CPU
,
ALL_LAYOUT
,
pten
::
Sign
,
float
,
double
)
{}
paddle/pten/kernels/gpu/math.cu
浏览文件 @
bb38b6aa
...
...
@@ -17,7 +17,6 @@ limitations under the License. */
#include "paddle/fluid/operators/reduce_ops/reduce_functor_op.h"
#include "paddle/pten/kernels/hybird/cuda/elementwise/elementwise.h"
#include "paddle/pten/kernels/hybird/cuda/reduce/reduce.h"
#include "paddle/pten/kernels/hybird/eigen/sign.h"
#include "paddle/pten/kernels/hybird/general/elementwise_functor.h"
#include "paddle/pten/kernels/hybird/general/reduce_impl.h"
...
...
@@ -57,11 +56,6 @@ struct DivideFunctor {
* Kernels
*/
template
<
typename
T
>
void
Sign
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
eigen
::
Sign
<
GPUContext
,
T
>
(
dev_ctx
,
x
,
out
);
}
template
<
typename
T
>
void
Mean
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
@@ -101,7 +95,6 @@ using float16 = paddle::platform::float16;
using
complex64
=
::
paddle
::
platform
::
complex
<
float
>
;
using
complex128
=
::
paddle
::
platform
::
complex
<
double
>
;
PT_REGISTER_KERNEL
(
sign
,
GPU
,
ALL_LAYOUT
,
pten
::
Sign
,
float
,
double
,
float16
)
{}
PT_REGISTER_KERNEL
(
mean
,
GPU
,
ALL_LAYOUT
,
pten
::
Mean
,
float
,
double
,
bool
)
{}
PT_REGISTER_KERNEL
(
add
,
GPU
,
...
...
paddle/pten/kernels/gpu/math.h
浏览文件 @
bb38b6aa
...
...
@@ -23,9 +23,6 @@ limitations under the License. */
namespace
pten
{
template
<
typename
T
>
void
Sign
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
);
template
<
typename
T
>
void
Mean
(
const
GPUContext
&
dev_ctx
,
const
DenseTensor
&
x
,
...
...
paddle/pten/kernels/gpu/sign_kernel.cu
0 → 100644
浏览文件 @
bb38b6aa
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "paddle/pten/kernels/impl/sign_kernel_impl.h"
#include "paddle/pten/kernels/sign_kernel.h"
#include "paddle/pten/backends/gpu/gpu_context.h"
#include "paddle/pten/core/kernel_registry.h"
// See Note [ Why still include the fluid headers? ]
#include "paddle/fluid/platform/float16.h"
using
float16
=
paddle
::
platform
::
float16
;
PT_REGISTER_CTX_KERNEL
(
sign
,
GPU
,
ALL_LAYOUT
,
pten
::
Sign
,
float
,
double
,
float16
)
{}
paddle/pten/kernels/impl/sign_kernel_impl.h
0 → 100644
浏览文件 @
bb38b6aa
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include "paddle/pten/core/dense_tensor.h"
#include "paddle/pten/kernels/hybird/eigen/common.h"
// See Note [ Why still include the fluid headers? ]
#include "paddle/fluid/operators/eigen/eigen_function.h"
namespace
pten
{
template
<
typename
T
,
typename
ContextT
>
void
Sign
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
)
{
out
->
mutable_data
<
T
>
();
auto
eigen_out
=
pten
::
EigenVector
<
T
>::
Flatten
(
*
out
);
auto
eigen_x
=
pten
::
EigenVector
<
T
>::
Flatten
(
x
);
auto
&
dev
=
*
dev_ctx
.
eigen_device
();
paddle
::
operators
::
EigenSign
<
std
::
decay_t
<
decltype
(
dev
)
>
,
T
>::
Eval
(
dev
,
eigen_out
,
eigen_x
);
}
}
// namespace pten
paddle/pten/kernels/sign_kernel.h
0 → 100644
浏览文件 @
bb38b6aa
/* Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#include "paddle/pten/core/dense_tensor.h"
namespace
pten
{
template
<
typename
T
,
typename
ContextT
>
void
Sign
(
const
ContextT
&
dev_ctx
,
const
DenseTensor
&
x
,
DenseTensor
*
out
);
}
// namespace pten
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录