Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
259b18a7
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
259b18a7
编写于
7月 04, 2023
作者:
R
RedContritio
提交者:
GitHub
7月 04, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support auto generate for op elementwise_heaviside (#55029)
上级
4a143fe0
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
109 deletion
+25
-109
paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc
...e/fluid/operators/elementwise/elementwise_heaviside_op.cc
+0
-73
paddle/phi/api/yaml/backward.yaml
paddle/phi/api/yaml/backward.yaml
+11
-0
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+0
-10
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-9
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+5
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+9
-0
paddle/phi/ops/compat/elementwise_sig.cc
paddle/phi/ops/compat/elementwise_sig.cc
+0
-17
未找到文件。
paddle/fluid/operators/elementwise/elementwise_heaviside_op.cc
已删除
100644 → 0
浏览文件 @
4a143fe0
// 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 <string>
#include "paddle/fluid/operators/elementwise/elementwise_op.h"
namespace
paddle
{
namespace
operators
{
class
ElementwiseHeavisideOpMaker
:
public
ElementwiseOpMaker
{
protected:
std
::
string
GetName
()
const
override
{
return
"Heaviside"
;
}
std
::
string
GetEquation
()
const
override
{
return
"Out = Heaviside(X, Y)"
;
}
void
AddInputX
()
override
{
AddInput
(
"X"
,
"(Tensor), The input tensor of Heaviside step function. "
"Its dtype can be int32, int64, float32 and float64"
);
}
void
AddInputY
()
override
{
AddInput
(
"Y"
,
"(Tensor), The tensor determining a Heaviside step function, "
"which is the value when X = 0. Its dtype should be same as X."
);
}
std
::
string
GetOpFunctionality
()
const
override
{
return
"Computes the Heaviside step function determined by Y "
"for each element in X."
;
}
};
template
<
typename
T
>
class
ElementwiseHeavisideGradOpMaker
:
public
framework
::
SingleGradOpMaker
<
T
>
{
public:
using
framework
::
SingleGradOpMaker
<
T
>::
SingleGradOpMaker
;
protected:
void
Apply
(
GradOpPtr
<
T
>
op
)
const
override
{
op
->
SetType
(
"elementwise_heaviside_grad"
);
op
->
SetInput
(
"X"
,
this
->
Input
(
"X"
));
op
->
SetInput
(
"Y"
,
this
->
Input
(
"Y"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
this
->
OutputGrad
(
"Out"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
this
->
InputGrad
(
"X"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Y"
),
this
->
InputGrad
(
"Y"
));
op
->
SetAttrMap
(
this
->
Attrs
());
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
REGISTER_OPERATOR
(
elementwise_heaviside
,
ops
::
ElementwiseOp
,
ops
::
ElementwiseHeavisideOpMaker
,
ops
::
ElementwiseHeavisideGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
ElementwiseHeavisideGradOpMaker
<
paddle
::
imperative
::
OpBase
>
);
REGISTER_OPERATOR
(
elementwise_heaviside_grad
,
ops
::
ElementwiseOpGrad
);
paddle/phi/api/yaml/backward.yaml
浏览文件 @
259b18a7
...
...
@@ -994,6 +994,17 @@
func
:
hardtanh_grad
inplace
:
(out_grad -> x_grad)
-
backward_op
:
heaviside_grad
forward
:
heaviside (Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
param
:
[
x
,
y
]
kernel
:
func
:
heaviside_grad
data_type
:
out_grad
-
backward_op
:
huber_loss_grad
forward
:
huber_loss (Tensor input, Tensor label, float delta) -> Tensor(out), Tensor(residual)
args
:
(Tensor residual, Tensor out_grad, float delta)
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
259b18a7
...
...
@@ -263,16 +263,6 @@
func
:
hardswish_grad
inplace
:
(out_grad -> x_grad)
-
backward_op
:
heaviside_grad
forward
:
heaviside (Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad)
infer_meta
:
func
:
GeneralBinaryGradInferMeta
param
:
[
x
,
y
]
kernel
:
func
:
heaviside_grad
-
backward_op
:
hsigmoid_loss_grad
forward
:
hsigmoid_loss (Tensor x, Tensor label, Tensor w, Tensor bias, Tensor path, Tensor code, int num_classes, bool is_sparse) -> Tensor(out), Tensor(pre_out), Tensor(w_out)
args
:
(Tensor x, Tensor w, Tensor label, Tensor path, Tensor code, Tensor bias, Tensor pre_out, Tensor out_grad, int num_classes, bool is_sparse)
...
...
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
259b18a7
...
...
@@ -435,15 +435,6 @@
func
:
hardswish
backward
:
hardswish_grad
-
op
:
heaviside
args
:
(Tensor x, Tensor y)
output
:
Tensor
infer_meta
:
func
:
ElementwiseInferMeta
kernel
:
func
:
heaviside
backward
:
heaviside_grad
-
op
:
hsigmoid_loss
args
:
(Tensor x, Tensor label, Tensor w, Tensor bias, Tensor path, Tensor code, int num_classes, bool is_sparse)
output
:
Tensor(out), Tensor(pre_out), Tensor(w_out)
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
259b18a7
...
...
@@ -1284,9 +1284,14 @@
-
op
:
heaviside (elementwise_heaviside)
backward
:
heaviside_grad (elementwise_heaviside_grad)
inputs
:
{
x
:
X
,
y
:
Y
}
outputs
:
{
out
:
Out
}
extra
:
attrs
:
[
bool use_mkldnn = false
,
str mkldnn_data_type = "float32"
,
bool use_quantizer = false
,
float Scale_x = 1.0f
,
float Scale_y = 1.0f
,
float Scale_out = 1.0f
]
complex_promote
:
[
X
,
Y
]
-
op
:
histogram
inputs
:
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
259b18a7
...
...
@@ -1081,6 +1081,15 @@
func
:
hardtanh
backward
:
hardtanh_grad
-
op
:
heaviside
args
:
(Tensor x, Tensor y)
output
:
Tensor(out)
infer_meta
:
func
:
ElementwiseInferMeta
kernel
:
func
:
heaviside
backward
:
heaviside_grad
-
op
:
histogram
args
:
(Tensor input, int64_t bins = 100, int min = 0, int max = 0)
output
:
Tensor(out)
...
...
paddle/phi/ops/compat/elementwise_sig.cc
浏览文件 @
259b18a7
...
...
@@ -109,11 +109,6 @@ KernelSignature ElementwiseFloorDivOpArgumentMapping(
return
KernelSignature
(
"floor_divide_raw"
,
{
"X"
,
"Y"
},
{
"axis"
},
{
"Out"
});
}
KernelSignature
ElementwiseHeavisideOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
UNUSED
)
{
return
KernelSignature
(
"heaviside"
,
{
"X"
,
"Y"
},
{},
{
"Out"
});
}
KernelSignature
ElementwisePowOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
UNUSED
)
{
int
axis
=
paddle
::
any_cast
<
int
>
(
ctx
.
Attr
(
"axis"
));
...
...
@@ -216,12 +211,6 @@ KernelSignature ElementwiseMinGradOpArgumentMapping(
"minimum_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
});
}
KernelSignature
ElementwiseHeavisideGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
UNUSED
)
{
return
KernelSignature
(
"heaviside_grad"
,
{
"X"
,
"Y"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
});
}
KernelSignature
ElementwisePowGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
UNUSED
)
{
return
KernelSignature
(
...
...
@@ -237,7 +226,6 @@ PD_REGISTER_BASE_KERNEL_NAME(elementwise_max, maximum);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_min
,
minimum
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_mod
,
remainder
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_floordiv
,
floor_divide
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_heaviside
,
heaviside
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_add_grad
,
add_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_add_grad_grad
,
add_double_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_add_triple_grad
,
add_triple_grad
);
...
...
@@ -252,7 +240,6 @@ PD_REGISTER_BASE_KERNEL_NAME(elementwise_fmax, fmax);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_fmin
,
fmin
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_fmin_grad
,
fmin_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_min_grad
,
minimum_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
elementwise_heaviside_grad
,
heaviside_grad
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_add
,
phi
::
ElementwiseAddOpArgumentMapping
);
...
...
@@ -270,8 +257,6 @@ PD_REGISTER_ARG_MAPPING_FN(elementwise_mod,
phi
::
ElementwiseModOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_floordiv
,
phi
::
ElementwiseFloorDivOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_heaviside
,
phi
::
ElementwiseHeavisideOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_pow
,
phi
::
ElementwisePowOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_add_grad
,
...
...
@@ -302,8 +287,6 @@ PD_REGISTER_ARG_MAPPING_FN(elementwise_fmin_grad,
phi
::
ElementwiseFMinGradOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_min_grad
,
phi
::
ElementwiseMinGradOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_heaviside_grad
,
phi
::
ElementwiseHeavisideGradOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
elementwise_pow_grad
,
phi
::
ElementwisePowGradOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
grad_add
,
phi
::
ElementwiseGradAddOpArgumentMapping
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录