Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
csdn_franckjun
Paddle
提交
246ac976
P
Paddle
项目概览
csdn_franckjun
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
246ac976
编写于
7月 14, 2022
作者:
Y
Yuang Liu
提交者:
GitHub
7月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[operator migration] Migrate infer shape for merged momentum (#44338)
上级
4baf0dbe
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
59 addition
and
3 deletion
+59
-3
paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py
...uto_code_generator/final_state_generator/codegen_utils.py
+1
-0
paddle/fluid/operators/optimizers/merged_momentum_op.cc
paddle/fluid/operators/optimizers/merged_momentum_op.cc
+9
-3
paddle/phi/api/lib/data_transform.cc
paddle/phi/api/lib/data_transform.cc
+10
-0
paddle/phi/api/lib/data_transform.h
paddle/phi/api/lib/data_transform.h
+5
-0
paddle/phi/api/yaml/generator/api_base.py
paddle/phi/api/yaml/generator/api_base.py
+2
-0
paddle/phi/infermeta/multiary.cc
paddle/phi/infermeta/multiary.cc
+16
-0
paddle/phi/infermeta/multiary.h
paddle/phi/infermeta/multiary.h
+16
-0
未找到文件。
paddle/fluid/eager/auto_code_generator/final_state_generator/codegen_utils.py
浏览文件 @
246ac976
...
...
@@ -45,6 +45,7 @@ yaml_types_mapping = {
'int'
:
'int'
,
'int32_t'
:
'int32_t'
,
'int64_t'
:
'int64_t'
,
'size_t'
:
'size_t'
,
\
'float'
:
'float'
,
'double'
:
'double'
,
'bool'
:
'bool'
,
\
'str'
:
'std::string'
,
\
'str[]'
:
'std::vector<std::string>'
,
'float[]'
:
'std::vector<float>'
,
\
'Place'
:
'paddle::Place'
,
'DataLayout'
:
'paddle::experimental::DataLayout'
,
'DataType'
:
'paddle::experimental::DataType'
,
\
'int64_t[]'
:
'std::vector<int64_t>'
,
'int[]'
:
'std::vector<int>'
,
'Tensor'
:
'Tensor'
,
...
...
paddle/fluid/operators/optimizers/merged_momentum_op.cc
浏览文件 @
246ac976
...
...
@@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#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/multiary.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -22,8 +25,6 @@ class MergedMomentumOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
protected:
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{}
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
param_dtype
=
...
...
@@ -100,6 +101,11 @@ class MergedMomentumOpMaker : public framework::OpProtoAndCheckerMaker {
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
DECLARE_INFER_SHAPE_FUNCTOR
(
merged_momentum
,
MergedMomentumInferShapeFunctor
,
PD_INFER_META
(
phi
::
MergedMomentumInferMeta
));
REGISTER_OP_WITHOUT_GRADIENT
(
merged_momentum
,
ops
::
MergedMomentumOp
,
ops
::
MergedMomentumOpMaker
);
ops
::
MergedMomentumOpMaker
,
MergedMomentumInferShapeFunctor
);
paddle/phi/api/lib/data_transform.cc
浏览文件 @
246ac976
...
...
@@ -284,5 +284,15 @@ std::unique_ptr<std::vector<phi::DenseTensor>> PrepareData(
return
pt_tensors
;
}
paddle
::
optional
<
std
::
vector
<
phi
::
DenseTensor
>>
PrepareData
(
const
paddle
::
optional
<
std
::
vector
<
Tensor
>>&
inputs
,
const
phi
::
TensorArgDef
&
target_args_def
,
const
TransformFlag
&
transform_flag
)
{
if
(
inputs
)
{
return
{
*
PrepareData
(
*
inputs
,
target_args_def
,
transform_flag
)};
}
return
paddle
::
none
;
}
}
// namespace experimental
}
// namespace paddle
paddle/phi/api/lib/data_transform.h
浏览文件 @
246ac976
...
...
@@ -76,5 +76,10 @@ std::unique_ptr<std::vector<phi::DenseTensor>> PrepareData(
const
phi
::
TensorArgDef
&
target_args_def
,
const
TransformFlag
&
transform_flag
);
paddle
::
optional
<
std
::
vector
<
phi
::
DenseTensor
>>
PrepareData
(
const
paddle
::
optional
<
std
::
vector
<
Tensor
>>&
inputs
,
const
phi
::
TensorArgDef
&
target_args_def
,
const
TransformFlag
&
transform_flag
);
}
// namespace experimental
}
// namespace paddle
paddle/phi/api/yaml/generator/api_base.py
浏览文件 @
246ac976
...
...
@@ -131,9 +131,11 @@ class BaseAPI(object):
'long'
:
'long'
,
'size_t'
:
'size_t'
,
'float'
:
'float'
,
'float[]'
:
'const std::vector<float>&'
,
'double'
:
'double'
,
'bool'
:
'bool'
,
'str'
:
'const std::string&'
,
'str[] '
:
'const std::vector<std::string>&'
,
'Place'
:
'const Place&'
,
'DataLayout'
:
'DataLayout'
,
'DataType'
:
'DataType'
,
...
...
paddle/phi/infermeta/multiary.cc
浏览文件 @
246ac976
...
...
@@ -1549,6 +1549,22 @@ void MergedAdamInferMeta(
std
::
vector
<
MetaTensor
*>
beta2_pow_out
,
std
::
vector
<
MetaTensor
*>
master_param_out
)
{}
void
MergedMomentumInferMeta
(
const
std
::
vector
<
const
MetaTensor
*>&
param
,
const
std
::
vector
<
const
MetaTensor
*>&
grad
,
const
std
::
vector
<
const
MetaTensor
*>&
velocity
,
const
std
::
vector
<
const
MetaTensor
*>&
learning_rate
,
const
paddle
::
optional
<
std
::
vector
<
const
MetaTensor
*>>&
master_param
,
float
mu
,
bool
use_nesterov
,
const
std
::
vector
<
std
::
string
>&
regularization_method
,
const
std
::
vector
<
float
>&
regularization_coeff
,
bool
multi_precision
,
float
rescale_grad
,
std
::
vector
<
MetaTensor
*>
param_out
,
std
::
vector
<
MetaTensor
*>
velocity_out
,
std
::
vector
<
MetaTensor
*>
master_param_out
)
{}
void
MeshgridInferMeta
(
const
std
::
vector
<
const
MetaTensor
*>&
inputs
,
std
::
vector
<
MetaTensor
*>
outputs
)
{
const
size_t
inputs_num
=
inputs
.
size
();
...
...
paddle/phi/infermeta/multiary.h
浏览文件 @
246ac976
...
...
@@ -255,6 +255,22 @@ void MergedAdamInferMeta(
std
::
vector
<
MetaTensor
*>
beta2_pow_out
,
std
::
vector
<
MetaTensor
*>
master_param_out
);
void
MergedMomentumInferMeta
(
const
std
::
vector
<
const
MetaTensor
*>&
param
,
const
std
::
vector
<
const
MetaTensor
*>&
grad
,
const
std
::
vector
<
const
MetaTensor
*>&
velocity
,
const
std
::
vector
<
const
MetaTensor
*>&
learning_rate
,
const
paddle
::
optional
<
std
::
vector
<
const
MetaTensor
*>>&
master_param
,
float
mu
,
bool
use_nesterov
,
const
std
::
vector
<
std
::
string
>&
regularization_method
,
const
std
::
vector
<
float
>&
regularization_coeff
,
bool
multi_precision
,
float
rescale_grad
,
std
::
vector
<
MetaTensor
*>
param_out
,
std
::
vector
<
MetaTensor
*>
velocity_out
,
std
::
vector
<
MetaTensor
*>
master_param_out
);
void
MeshgridInferMeta
(
const
std
::
vector
<
const
MetaTensor
*>&
inputs
,
std
::
vector
<
MetaTensor
*>
outputs
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录