Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
c6272b6a
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看板
未验证
提交
c6272b6a
编写于
7月 14, 2022
作者:
Z
zhangkaihuo
提交者:
GitHub
7月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some Ops support fp16 (#44295)
* sparse support amp * EagerAmpAutoCasts support sparse
上级
dc5a0420
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
14 deletion
+40
-14
paddle/fluid/eager/eager_amp_auto_cast.h
paddle/fluid/eager/eager_amp_auto_cast.h
+23
-12
paddle/phi/kernels/gpu/pad3d_grad_kernel.cu
paddle/phi/kernels/gpu/pad3d_grad_kernel.cu
+7
-2
paddle/phi/kernels/sparse/empty_kernel.cc
paddle/phi/kernels/sparse/empty_kernel.cc
+2
-0
paddle/phi/kernels/sparse/gpu/unary_grad_kernel.cu
paddle/phi/kernels/sparse/gpu/unary_grad_kernel.cu
+4
-0
paddle/phi/kernels/sparse/gpu/unary_kernel.cu
paddle/phi/kernels/sparse/gpu/unary_kernel.cu
+4
-0
未找到文件。
paddle/fluid/eager/eager_amp_auto_cast.h
浏览文件 @
c6272b6a
...
@@ -39,6 +39,27 @@ static inline bool NeedCast(const paddle::experimental::Tensor& tensor,
...
@@ -39,6 +39,27 @@ static inline bool NeedCast(const paddle::experimental::Tensor& tensor,
return
false
;
return
false
;
}
}
inline
paddle
::
experimental
::
Tensor
Cast
(
const
paddle
::
experimental
::
Tensor
&
input
,
const
paddle
::
experimental
::
DataType
&
dst_dtype
,
const
bool
trace_backward
=
true
)
{
if
(
input
.
is_sparse_coo_tensor
()
||
input
.
is_sparse_csr_tensor
())
{
if
(
trace_backward
)
{
return
sparse
::
cast_final_state_dygraph_function
(
input
,
paddle
::
experimental
::
DataType
::
UNDEFINED
,
dst_dtype
);
}
else
{
return
paddle
::
experimental
::
sparse
::
cast
(
input
,
paddle
::
experimental
::
DataType
::
UNDEFINED
,
dst_dtype
);
}
}
else
{
if
(
trace_backward
)
{
return
cast_final_state_dygraph_function
(
input
,
dst_dtype
);
}
else
{
return
paddle
::
experimental
::
cast
(
input
,
dst_dtype
);
}
}
}
inline
std
::
vector
<
paddle
::
experimental
::
Tensor
>
EagerAmpAutoCasts
(
inline
std
::
vector
<
paddle
::
experimental
::
Tensor
>
EagerAmpAutoCasts
(
const
std
::
string
&
inputs_name
,
const
std
::
string
&
inputs_name
,
const
std
::
vector
<
paddle
::
experimental
::
Tensor
>&
inputs
,
const
std
::
vector
<
paddle
::
experimental
::
Tensor
>&
inputs
,
...
@@ -51,13 +72,7 @@ inline std::vector<paddle::experimental::Tensor> EagerAmpAutoCasts(
...
@@ -51,13 +72,7 @@ inline std::vector<paddle::experimental::Tensor> EagerAmpAutoCasts(
std
::
vector
<
paddle
::
experimental
::
Tensor
>
inputs_casted
;
std
::
vector
<
paddle
::
experimental
::
Tensor
>
inputs_casted
;
for
(
auto
&
input
:
inputs
)
{
for
(
auto
&
input
:
inputs
)
{
if
(
NeedCast
(
input
,
dst_dtype
))
{
if
(
NeedCast
(
input
,
dst_dtype
))
{
if
(
trace_backward
)
{
inputs_casted
.
emplace_back
(
std
::
move
(
Cast
(
input
,
dst_dtype
)));
inputs_casted
.
emplace_back
(
std
::
move
(
cast_final_state_dygraph_function
(
input
,
dst_dtype
)));
}
else
{
inputs_casted
.
emplace_back
(
std
::
move
(
paddle
::
experimental
::
cast
(
input
,
dst_dtype
)));
}
}
else
{
}
else
{
inputs_casted
.
emplace_back
(
input
);
inputs_casted
.
emplace_back
(
input
);
}
}
...
@@ -92,11 +107,7 @@ inline paddle::experimental::Tensor EagerAmpAutoCast(
...
@@ -92,11 +107,7 @@ inline paddle::experimental::Tensor EagerAmpAutoCast(
}
}
}
}
if
(
NeedCast
(
input
,
dst_dtype
))
{
if
(
NeedCast
(
input
,
dst_dtype
))
{
if
(
trace_backward
)
{
return
Cast
(
input
,
dst_dtype
,
trace_backward
);
return
cast_final_state_dygraph_function
(
input
,
dst_dtype
);
}
else
{
return
paddle
::
experimental
::
cast
(
input
,
dst_dtype
);
}
}
}
return
input
;
return
input
;
}
}
...
...
paddle/phi/kernels/gpu/pad3d_grad_kernel.cu
浏览文件 @
c6272b6a
...
@@ -503,5 +503,10 @@ void Pad3dGradKernel(const Context& dev_ctx,
...
@@ -503,5 +503,10 @@ void Pad3dGradKernel(const Context& dev_ctx,
}
// namespace phi
}
// namespace phi
PD_REGISTER_KERNEL
(
PD_REGISTER_KERNEL
(
pad3d_grad
,
pad3d_grad
,
GPU
,
ALL_LAYOUT
,
phi
::
Pad3dGradKernel
,
float
,
double
)
{}
GPU
,
ALL_LAYOUT
,
phi
::
Pad3dGradKernel
,
float
,
double
,
phi
::
dtype
::
float16
)
{}
paddle/phi/kernels/sparse/empty_kernel.cc
浏览文件 @
c6272b6a
...
@@ -97,6 +97,7 @@ PD_REGISTER_KERNEL(empty_like_coo,
...
@@ -97,6 +97,7 @@ PD_REGISTER_KERNEL(empty_like_coo,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
EmptyLikeCooKernel
,
phi
::
sparse
::
EmptyLikeCooKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
@@ -112,6 +113,7 @@ PD_REGISTER_KERNEL(empty_like_csr,
...
@@ -112,6 +113,7 @@ PD_REGISTER_KERNEL(empty_like_csr,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
EmptyLikeCsrKernel
,
phi
::
sparse
::
EmptyLikeCsrKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
...
paddle/phi/kernels/sparse/gpu/unary_grad_kernel.cu
浏览文件 @
c6272b6a
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
GPU, \
GPU, \
ALL_LAYOUT, \
ALL_LAYOUT, \
phi::sparse::prefix##CooGradKernel, \
phi::sparse::prefix##CooGradKernel, \
phi::dtype::float16, \
float, \
float, \
double) { \
double) { \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_COO); \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_COO); \
...
@@ -32,6 +33,7 @@
...
@@ -32,6 +33,7 @@
GPU, \
GPU, \
ALL_LAYOUT, \
ALL_LAYOUT, \
phi::sparse::prefix##CsrGradKernel, \
phi::sparse::prefix##CsrGradKernel, \
phi::dtype::float16, \
float, \
float, \
double) { \
double) { \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_CSR); \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_CSR); \
...
@@ -56,6 +58,7 @@ PD_REGISTER_KERNEL(cast_coo_grad,
...
@@ -56,6 +58,7 @@ PD_REGISTER_KERNEL(cast_coo_grad,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
CastCooGradKernel
,
phi
::
sparse
::
CastCooGradKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
@@ -69,6 +72,7 @@ PD_REGISTER_KERNEL(cast_csr_grad,
...
@@ -69,6 +72,7 @@ PD_REGISTER_KERNEL(cast_csr_grad,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
CastCsrGradKernel
,
phi
::
sparse
::
CastCsrGradKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
...
paddle/phi/kernels/sparse/gpu/unary_kernel.cu
浏览文件 @
c6272b6a
...
@@ -67,6 +67,7 @@ void DivCsrScalarKernel(const Context& dev_ctx,
...
@@ -67,6 +67,7 @@ void DivCsrScalarKernel(const Context& dev_ctx,
GPU, \
GPU, \
ALL_LAYOUT, \
ALL_LAYOUT, \
phi::sparse::prefix##CooKernel, \
phi::sparse::prefix##CooKernel, \
phi::dtype::float16, \
float, \
float, \
double) { \
double) { \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_COO); \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_COO); \
...
@@ -76,6 +77,7 @@ void DivCsrScalarKernel(const Context& dev_ctx,
...
@@ -76,6 +77,7 @@ void DivCsrScalarKernel(const Context& dev_ctx,
GPU, \
GPU, \
ALL_LAYOUT, \
ALL_LAYOUT, \
phi::sparse::prefix##CsrKernel, \
phi::sparse::prefix##CsrKernel, \
phi::dtype::float16, \
float, \
float, \
double) { \
double) { \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_CSR); \
kernel->InputAt(0).SetDataLayout(phi::DataLayout::SPARSE_CSR); \
...
@@ -119,6 +121,7 @@ PD_REGISTER_KERNEL(cast_coo,
...
@@ -119,6 +121,7 @@ PD_REGISTER_KERNEL(cast_coo,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
CastCooKernel
,
phi
::
sparse
::
CastCooKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
@@ -132,6 +135,7 @@ PD_REGISTER_KERNEL(cast_csr,
...
@@ -132,6 +135,7 @@ PD_REGISTER_KERNEL(cast_csr,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
sparse
::
CastCsrKernel
,
phi
::
sparse
::
CastCsrKernel
,
phi
::
dtype
::
float16
,
float
,
float
,
double
,
double
,
int8_t
,
int8_t
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录