Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
d73eb38c
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看板
未验证
提交
d73eb38c
编写于
5月 06, 2022
作者:
A
Aganlengzi
提交者:
GitHub
5月 06, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[NPU] support model PPO (#42484)
上级
1588e7e7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
36 addition
and
11 deletion
+36
-11
paddle/fluid/operators/elementwise/elementwise_div_op_npu.cc
paddle/fluid/operators/elementwise/elementwise_div_op_npu.cc
+36
-11
未找到文件。
paddle/fluid/operators/elementwise/elementwise_div_op_npu.cc
浏览文件 @
d73eb38c
...
@@ -118,20 +118,45 @@ class ElementwiseDivGradNPUKernel : public framework::OpKernel<T> {
...
@@ -118,20 +118,45 @@ class ElementwiseDivGradNPUKernel : public framework::OpKernel<T> {
if
(
dy
)
{
if
(
dy
)
{
dy
->
mutable_data
<
T
>
(
place
);
dy
->
mutable_data
<
T
>
(
place
);
Tensor
neg_out
(
y
->
type
());
Tensor
neg_out
(
out
->
type
());
neg_out
.
mutable_data
<
T
>
(
y
->
dims
(),
place
);
neg_out
.
mutable_data
<
T
>
(
out
->
dims
(),
place
);
const
auto
&
runner_neg_out
=
NpuOpRunner
(
"Neg"
,
{
*
out
},
{
neg_out
},
{});
const
auto
&
runner_neg_out
=
NpuOpRunner
(
"Neg"
,
{
*
out
},
{
neg_out
},
{});
runner_neg_out
.
Run
(
stream
);
runner_neg_out
.
Run
(
stream
);
Tensor
y_grad_w
(
y
->
type
());
Tensor
tmp_mul
(
out
->
type
());
y_grad_w
.
mutable_data
<
T
>
(
y
->
dims
(),
place
);
tmp_mul
.
mutable_data
<
T
>
(
out
->
dims
(),
place
);
const
auto
&
runner_y_grad_w
=
const
auto
&
runner_mul
=
NpuOpRunner
(
"Div"
,
{
neg_out
,
*
y
},
{
y_grad_w
},
{});
NpuOpRunner
(
"Mul"
,
{
neg_out
,
*
dout
},
{
tmp_mul
},
{});
runner_y_grad_w
.
Run
(
stream
);
runner_mul
.
Run
(
stream
);
const
auto
&
runner_y_grad
=
if
(
dy
->
dims
()
!=
dout
->
dims
())
{
NpuOpRunner
(
"Mul"
,
{
y_grad_w
,
*
dout
},
{
*
dy
},
{});
Tensor
reduced_tmp_mul
(
y
->
type
());
runner_y_grad
.
Run
(
stream
);
reduced_tmp_mul
.
mutable_data
<
T
>
(
y
->
dims
(),
place
);
std
::
vector
<
int64_t
>
axes
;
int64_t
diff
=
dout
->
dims
().
size
()
-
dy
->
dims
().
size
();
for
(
int64_t
i
=
0
;
i
<
dout
->
dims
().
size
();
++
i
)
{
if
(
i
<
diff
)
{
axes
.
push_back
(
i
);
continue
;
}
if
(
dout
->
dims
()[
i
]
>
dy
->
dims
()[
i
-
diff
])
{
axes
.
push_back
(
i
);
}
}
const
auto
&
runner_reduce
=
NpuOpRunner
(
"ReduceSumD"
,
{
tmp_mul
},
{
reduced_tmp_mul
},
{{
"axes"
,
axes
},
{
"keep_dims"
,
false
}});
runner_reduce
.
Run
(
stream
);
const
auto
&
runner_y_grad
=
NpuOpRunner
(
"Div"
,
{
reduced_tmp_mul
,
*
y
},
{
*
dy
},
{});
runner_y_grad
.
Run
(
stream
);
}
else
{
const
auto
&
runner_y_grad
=
NpuOpRunner
(
"Div"
,
{
tmp_mul
,
*
y
},
{
*
dy
},
{});
runner_y_grad
.
Run
(
stream
);
}
}
}
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录