Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d15b490a
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
未验证
提交
d15b490a
编写于
7月 14, 2022
作者:
Y
Yuang Liu
提交者:
GitHub
7月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[operator migration] Migrate merged momentum cpu/gpu kernels (#44300)
上级
84b72c5f
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
538 addition
and
24 deletion
+538
-24
paddle/fluid/operators/optimizers/merged_momentum_op.cc
paddle/fluid/operators/optimizers/merged_momentum_op.cc
+1
-5
paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc
paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc
+7
-1
paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc
paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc
+6
-1
paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h
...d/operators/optimizers/pow2_decay_with_linear_warmup_op.h
+1
-1
paddle/fluid/platform/macros.h
paddle/fluid/platform/macros.h
+0
-6
paddle/phi/core/macros.h
paddle/phi/core/macros.h
+6
-0
paddle/phi/kernels/cpu/merged_momentum_kernel.cc
paddle/phi/kernels/cpu/merged_momentum_kernel.cc
+10
-10
paddle/phi/kernels/gpu/merged_momentum_kernel.cu
paddle/phi/kernels/gpu/merged_momentum_kernel.cu
+25
-0
paddle/phi/kernels/impl/merged_momentum_impl.h
paddle/phi/kernels/impl/merged_momentum_impl.h
+400
-0
paddle/phi/kernels/merged_momentum_kernel.h
paddle/phi/kernels/merged_momentum_kernel.h
+42
-0
paddle/phi/ops/compat/merged_momentum_sig.cc
paddle/phi/ops/compat/merged_momentum_sig.cc
+40
-0
未找到文件。
paddle/fluid/operators/optimizers/merged_momentum_op.cc
浏览文件 @
d15b490a
...
...
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/
operators/optimizers/merged_momentum_op
.h"
#include "paddle/fluid/
framework/op_registry
.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -103,7 +103,3 @@ namespace plat = paddle::platform;
REGISTER_OP_WITHOUT_GRADIENT
(
merged_momentum
,
ops
::
MergedMomentumOp
,
ops
::
MergedMomentumOpMaker
);
REGISTER_OP_CPU_KERNEL
(
merged_momentum
,
ops
::
MergedMomentumOpKernel
<
phi
::
CPUContext
,
float
>
,
ops
::
MergedMomentumOpKernel
<
phi
::
CPUContext
,
double
>
);
paddle/fluid/operators/optimizers/merged_momentum_op_mlu.cc
浏览文件 @
d15b490a
...
...
@@ -12,8 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/operators/amp/fp16_type_traits.h"
#include "paddle/fluid/operators/mlu/mlu_baseop.h"
#include "paddle/fluid/operators/optimizers/merged_momentum_op.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/phi/kernels/impl/momentum_kernel_impl.h"
namespace
paddle
{
namespace
operators
{
...
...
paddle/fluid/operators/optimizers/merged_momentum_op_npu.cc
浏览文件 @
d15b490a
...
...
@@ -12,8 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/optimizers/merged_momentum_op.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/operators/amp/fp16_type_traits.h"
#include "paddle/fluid/platform/device/npu/npu_op_runner.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/fluid/platform/macros.h"
#include "paddle/phi/kernels/impl/momentum_kernel_impl.h"
namespace
paddle
{
...
...
paddle/fluid/operators/optimizers/pow2_decay_with_linear_warmup_op.h
浏览文件 @
d15b490a
...
...
@@ -17,7 +17,7 @@
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/for_range.h"
#include "paddle/
fluid/platform
/macros.h"
#include "paddle/
phi/core
/macros.h"
namespace
paddle
{
namespace
operators
{
...
...
paddle/fluid/platform/macros.h
浏览文件 @
d15b490a
...
...
@@ -29,9 +29,3 @@ limitations under the License. */
#define FLT_MAX __FLT_MAX__
#endif // __FLT_MAX__
#endif // PADDLE_WITH_MUSL
#if defined(__NVCC__) || defined(__HIPCC__)
#define PADDLE_RESTRICT __restrict__
#else
#define PADDLE_RESTRICT
#endif
paddle/phi/core/macros.h
浏览文件 @
d15b490a
...
...
@@ -53,4 +53,10 @@ namespace phi {
#define PD_CONCATENATE2(arg1, arg2) arg1##arg2
#define PD_EXPAND(x) x
#if defined(__NVCC__) || defined(__HIPCC__)
#define PADDLE_RESTRICT __restrict__
#else
#define PADDLE_RESTRICT
#endif
}
// namespace phi
paddle/
fluid/operators/optimizers/merged_momentum_op.cu
→
paddle/
phi/kernels/cpu/merged_momentum_kernel.cc
浏览文件 @
d15b490a
// Copyright (c) 202
1
PaddlePaddle Authors. All Rights Reserved.
// Copyright (c) 202
2
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.
...
...
@@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/operators/optimizers/merged_momentum_op.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/merged_momentum_impl.h"
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
REGISTER_OP_CUDA_KERNEL
(
merged_momentum
,
ops
::
MergedMomentumOpKernel
<
plat
::
CUDADeviceContext
,
plat
::
float16
>
,
ops
::
MergedMomentumOpKernel
<
plat
::
CUDADeviceContext
,
float
>
,
ops
::
MergedMomentumOpKernel
<
plat
::
CUDADeviceContext
,
double
>
);
PD_REGISTER_KERNEL
(
merged_momentum
,
CPU
,
ALL_LAYOUT
,
phi
::
MergedMomentumKernel
,
float
,
double
)
{}
paddle/phi/kernels/gpu/merged_momentum_kernel.cu
0 → 100644
浏览文件 @
d15b490a
// Copyright (c) 2022 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/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/merged_momentum_impl.h"
PD_REGISTER_KERNEL
(
merged_momentum
,
GPU
,
ALL_LAYOUT
,
phi
::
MergedMomentumKernel
,
phi
::
dtype
::
float16
,
float
,
double
)
{}
paddle/
fluid/operators/optimizers/merged_momentum_op
.h
→
paddle/
phi/kernels/impl/merged_momentum_impl
.h
浏览文件 @
d15b490a
此差异已折叠。
点击以展开。
paddle/phi/kernels/merged_momentum_kernel.h
0 → 100644
浏览文件 @
d15b490a
// Copyright (c) 2022 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 <string>
#include <vector>
#include "paddle/phi/core/dense_tensor.h"
namespace
phi
{
template
<
typename
T
,
typename
Context
>
void
MergedMomentumKernel
(
const
Context
&
dev_ctx
,
const
std
::
vector
<
const
DenseTensor
*>&
param
,
const
std
::
vector
<
const
DenseTensor
*>&
grad
,
const
std
::
vector
<
const
DenseTensor
*>&
velocity
,
const
std
::
vector
<
const
DenseTensor
*>&
learning_rate
,
const
paddle
::
optional
<
std
::
vector
<
const
DenseTensor
*>>&
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
<
DenseTensor
*>
param_out
,
std
::
vector
<
DenseTensor
*>
velocity_out
,
std
::
vector
<
DenseTensor
*>
master_param_out
);
}
// namespace phi
paddle/phi/ops/compat/merged_momentum_sig.cc
0 → 100644
浏览文件 @
d15b490a
// Copyright (c) 2022 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/phi/core/compat/op_utils.h"
namespace
phi
{
KernelSignature
MergedMomentumOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"merged_momentum"
,
{
"Param"
,
"Grad"
,
"Velocity"
,
"LearningRate"
,
"MasterParam"
},
{
"mu"
,
"use_nesterov"
,
"regularization_method"
,
"regularization_coeff"
,
"multi_precision"
,
"rescale_grad"
},
{
"ParamOut"
,
"VelocityOut"
,
"MasterParamOut"
,
});
}
}
// namespace phi
PD_REGISTER_ARG_MAPPING_FN
(
merged_momentum
,
phi
::
MergedMomentumOpArgumentMapping
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录