Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
6cd3575c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
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看板
未验证
提交
6cd3575c
编写于
3月 30, 2023
作者:
W
Wang Xin
提交者:
GitHub
3月 30, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add autogen code support for merge_selected_rows (#52274)
* add autogen code support for merge_selected_rows * bug fixed
上级
336160cf
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
26 addition
and
101 deletion
+26
-101
paddle/fluid/operators/generator/filters.py
paddle/fluid/operators/generator/filters.py
+12
-0
paddle/fluid/operators/merge_selected_rows_op.cc
paddle/fluid/operators/merge_selected_rows_op.cc
+0
-93
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-8
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+6
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+8
-0
未找到文件。
paddle/fluid/operators/generator/filters.py
浏览文件 @
6cd3575c
...
...
@@ -40,6 +40,18 @@ def get_infer_var_type_func(op_name):
}}
}};
"""
elif
op_name
==
"merge_selected_rows"
:
return
f
"""
class
{
to_pascal_case
(
op_name
)
}
InferVarType
: public framework::PassInDtypeAndVarTypeToOutput {{
protected:
std::unordered_map<std::string, std::string>& GetInputOutputWithSameType()
const override {{
static std::unordered_map<std::string, std::string> m{{{{"X", /*->*/ "Out"}}}};
return m;
}}
}};
"""
else
:
return
None
...
...
paddle/fluid/operators/merge_selected_rows_op.cc
已删除
100644 → 0
浏览文件 @
336160cf
/* Copyright (c) 2018 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 <unordered_map>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"
namespace
paddle
{
namespace
operators
{
class
MergeSelectedRowsOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
};
class
MergeSelectedRowsOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"X"
,
"The input type is SelectedRows, and the selected rows may be "
"duplicated."
);
AddOutput
(
"Out"
,
"The output type is SelectedRows, and the selected rows are not "
"duplicated."
);
AddComment
(
R"DOC(
MergeSelectedRows Operator.
MergeSelectedRows is used to merge the duplicated rows of the input. The
output's row has no duplicated, and it's order is incremental.
Example:
Input:
X.rows is [0, 5, 5, 4, 19]
X.height is 20
X.value is:
[[1, 1]
[2, 2]
[3, 3]
[4, 4]
[6, 6]]
Output:
Out.row is [0, 4, 5, 19]
Out.height is 20
Out.value is:
[[1, 1]
[4, 4]
[5, 5]
[6, 6]]
)DOC"
);
}
};
class
MergeSelectedRowsOpInferVarType
:
public
framework
::
PassInDtypeAndVarTypeToOutput
{
protected:
std
::
unordered_map
<
std
::
string
,
std
::
string
>&
GetInputOutputWithSameType
()
const
override
{
static
std
::
unordered_map
<
std
::
string
,
std
::
string
>
m
{{
"X"
,
/*->*/
"Out"
}};
return
m
;
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
DECLARE_INFER_SHAPE_FUNCTOR
(
merge_selected_rows
,
MergeSelectedRowsInferMetaFunctor
,
PD_INFER_META
(
phi
::
UnchangedInferMeta
));
REGISTER_OPERATOR
(
merge_selected_rows
,
ops
::
MergeSelectedRowsOp
,
ops
::
MergeSelectedRowsOpMaker
,
ops
::
MergeSelectedRowsOpInferVarType
,
MergeSelectedRowsInferMetaFunctor
);
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
6cd3575c
...
...
@@ -1032,14 +1032,6 @@
func
:
mean_all
backward
:
mean_all_grad
-
op
:
merge_selected_rows
args
:
(Tensor x)
output
:
Tensor
infer_meta
:
func
:
UnchangedInferMeta
kernel
:
func
:
merge_selected_rows {selected_rows -> selected_rows}
-
op
:
merged_adam_
args
:
(Tensor[] param, Tensor[] grad, Tensor[] learning_rate, Tensor[] moment1, Tensor[] moment2, Tensor[] beta1_pow, Tensor[] beta2_pow, Tensor[] master_param, Scalar beta1, Scalar beta2, Scalar epsilon, bool multi_precision, bool use_global_beta_pow)
output
:
Tensor[](param_out){param.size()}, Tensor[](moment1_out){param.size()}, Tensor[](moment2_out){param.size()}, Tensor[](beta1_pow_out){param.size()}, Tensor[](beta2_pow_out){param.size()}, Tensor[](master_param_out){param.size()}
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
6cd3575c
...
...
@@ -1253,6 +1253,12 @@
extra
:
attrs
:
[
bool use_mkldnn = false
]
-
op
:
merge_selected_rows
inputs
:
x
:
X
outputs
:
out
:
Out
-
op
:
meshgrid
backward
:
meshgrid_grad
inputs
:
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
6cd3575c
...
...
@@ -1011,6 +1011,14 @@
optional
:
bias, cu_seqlens_q, cu_seqlens_k, causal_diagonal, seqlen_k
backward
:
memory_efficient_attention_grad
-
op
:
merge_selected_rows
args
:
(Tensor x)
output
:
Tensor(out)
infer_meta
:
func
:
UnchangedInferMeta
kernel
:
func
:
merge_selected_rows {selected_rows -> selected_rows}
-
op
:
meshgrid
args
:
(Tensor[] inputs)
output
:
Tensor[]{inputs.size()}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录