Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
90c3bddf
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看板
未验证
提交
90c3bddf
编写于
4月 10, 2023
作者:
G
gouzil
提交者:
GitHub
4月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Autogen code bilinear_tensor_product (#52690)
* add autogen code bilinear_tensor_product * [phi] rm cc file
上级
3ee2b237
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
25 addition
and
166 deletion
+25
-166
paddle/fluid/operators/bilinear_tensor_product_op.cc
paddle/fluid/operators/bilinear_tensor_product_op.cc
+0
-110
paddle/phi/api/yaml/backward.yaml
paddle/phi/api/yaml/backward.yaml
+9
-0
paddle/phi/api/yaml/legacy_backward.yaml
paddle/phi/api/yaml/legacy_backward.yaml
+0
-9
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-10
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
+10
-0
paddle/phi/ops/compat/bilinear_tensor_product_sig.cc
paddle/phi/ops/compat/bilinear_tensor_product_sig.cc
+0
-37
未找到文件。
paddle/fluid/operators/bilinear_tensor_product_op.cc
已删除
100644 → 0
浏览文件 @
3ee2b237
/* Copyright (c) 2016 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/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/backward.h"
#include "paddle/phi/infermeta/multiary.h"
namespace
paddle
{
namespace
operators
{
class
BilinearTensorProductOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
};
class
BilinearTensorProductOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"X"
,
"The first input of bilinear_tensor_product operator."
);
AddInput
(
"Y"
,
"The second input of bilinear_tensor_product operator."
);
AddInput
(
"Weight"
,
"The learnable parameters of bilinear_tensor_product operator."
);
AddInput
(
"Bias"
,
"The learnable bias of bilinear_tensor_product operator."
)
.
AsDispensable
();
AddOutput
(
"Out"
,
"The output of bilinear_tensor_product operator."
);
AddComment
(
R"DOC(
Bilinear Tensor Product operator.
Given input X and Y, a 3D tensor Weight and a Bias. Each column of the
Output is computed by one slice $i = 1, . . . , k$ of the tensor:
$$
M = (X W_i) * Y \\
Out_i = \sum_j {M_j} + Bias_i
$$
Where $W_i$ is the $i$-th slice of Input(Weight);
$M_j$ is the $j$-th column of $M$;
$Out_i$ is the $i$-th column of Output(Out);
$Bias_i$ is a column vector, each element of it is equal to
the $i$-th element of $Bias$;
)DOC"
);
}
};
class
BilinearTensorProductOpGrad
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
};
template
<
typename
T
>
class
BilinearTensorProductGradOpMaker
:
public
framework
::
SingleGradOpMaker
<
T
>
{
public:
using
framework
::
SingleGradOpMaker
<
T
>::
SingleGradOpMaker
;
protected:
void
Apply
(
GradOpPtr
<
T
>
op
)
const
override
{
op
->
SetType
(
"bilinear_tensor_product_grad"
);
op
->
SetAttrMap
(
this
->
Attrs
());
op
->
SetInput
(
"X"
,
this
->
Input
(
"X"
));
op
->
SetInput
(
"Y"
,
this
->
Input
(
"Y"
));
op
->
SetInput
(
"Weight"
,
this
->
Input
(
"Weight"
));
if
(
this
->
HasInput
(
"Bias"
))
{
op
->
SetOutput
(
framework
::
GradVarName
(
"Bias"
),
this
->
InputGrad
(
"Bias"
));
}
op
->
SetOutput
(
framework
::
GradVarName
(
"X"
),
this
->
InputGrad
(
"X"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Y"
),
this
->
InputGrad
(
"Y"
));
op
->
SetOutput
(
framework
::
GradVarName
(
"Weight"
),
this
->
InputGrad
(
"Weight"
));
op
->
SetInput
(
framework
::
GradVarName
(
"Out"
),
this
->
OutputGrad
(
"Out"
));
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
DECLARE_INFER_SHAPE_FUNCTOR
(
bilinear_tensor_product
,
BilinearTensorProductInferShapeFunctor
,
PD_INFER_META
(
phi
::
BilinearInferMeta
));
DECLARE_INFER_SHAPE_FUNCTOR
(
bilinear_tensor_product_grad
,
BilinearTensorProductGradInferShapeFunctor
,
PD_INFER_META
(
phi
::
BilinearTensorProductGradInferMeta
));
REGISTER_OPERATOR
(
bilinear_tensor_product
,
ops
::
BilinearTensorProductOp
,
ops
::
BilinearTensorProductOpMaker
,
ops
::
BilinearTensorProductGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
BilinearTensorProductGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
BilinearTensorProductInferShapeFunctor
);
REGISTER_OPERATOR
(
bilinear_tensor_product_grad
,
ops
::
BilinearTensorProductOpGrad
,
BilinearTensorProductGradInferShapeFunctor
);
paddle/phi/api/yaml/backward.yaml
浏览文件 @
90c3bddf
...
@@ -173,6 +173,15 @@
...
@@ -173,6 +173,15 @@
data_transform
:
data_transform
:
skip_transform
:
out_size, size_tensor, scale_tensor
skip_transform
:
out_size, size_tensor, scale_tensor
-
backward_op
:
bilinear_tensor_product_grad
forward
:
bilinear_tensor_product (Tensor x, Tensor y, Tensor weight, Tensor bias) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor weight, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad), Tensor(weight_grad), Tensor(bias_grad)
infer_meta
:
func
:
BilinearTensorProductGradInferMeta
kernel
:
func
:
bilinear_grad
-
backward_op
:
bmm_grad
-
backward_op
:
bmm_grad
forward
:
bmm (Tensor x, Tensor y) -> Tensor(out)
forward
:
bmm (Tensor x, Tensor y) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor out_grad)
args
:
(Tensor x, Tensor y, Tensor out_grad)
...
...
paddle/phi/api/yaml/legacy_backward.yaml
浏览文件 @
90c3bddf
...
@@ -122,15 +122,6 @@
...
@@ -122,15 +122,6 @@
composite
:
batch_norm_grad(x, scale, bias, mean_out, variance_out, saved_mean, saved_variance, reserve_space, out_grad, momentum, epsilon, data_layout, is_test, use_global_stats, trainable_statistics)
composite
:
batch_norm_grad(x, scale, bias, mean_out, variance_out, saved_mean, saved_variance, reserve_space, out_grad, momentum, epsilon, data_layout, is_test, use_global_stats, trainable_statistics)
backward
:
batch_norm_double_grad
backward
:
batch_norm_double_grad
-
backward_op
:
bilinear_tensor_product_grad
forward
:
bilinear_tensor_product (Tensor x, Tensor y, Tensor weight, Tensor bias) -> Tensor(out)
args
:
(Tensor x, Tensor y, Tensor weight, Tensor out_grad)
output
:
Tensor(x_grad), Tensor(y_grad), Tensor(weight_grad), Tensor(bias_grad)
infer_meta
:
func
:
BilinearTensorProductGradInferMeta
kernel
:
func
:
bilinear_grad
-
backward_op
:
cast_grad
-
backward_op
:
cast_grad
forward
:
cast (Tensor x, DataType dtype) -> Tensor(out)
forward
:
cast (Tensor x, DataType dtype) -> Tensor(out)
args
:
(Tensor x, Tensor out_grad)
args
:
(Tensor x, Tensor out_grad)
...
...
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
90c3bddf
...
@@ -186,16 +186,6 @@
...
@@ -186,16 +186,6 @@
view
:
(mean -> mean_out), (variance -> variance_out)
view
:
(mean -> mean_out), (variance -> variance_out)
backward
:
batch_norm_grad
backward
:
batch_norm_grad
-
op
:
bilinear_tensor_product
args
:
(Tensor x, Tensor y, Tensor weight, Tensor bias)
output
:
Tensor
infer_meta
:
func
:
BilinearInferMeta
kernel
:
func
:
bilinear
optional
:
bias
backward
:
bilinear_tensor_product_grad
-
op
:
bincount
-
op
:
bincount
args
:
(Tensor x, Tensor weights, Scalar(int) minlength = 0)
args
:
(Tensor x, Tensor weights, Scalar(int) minlength = 0)
output
:
Tensor(out)
output
:
Tensor(out)
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
90c3bddf
...
@@ -262,6 +262,12 @@
...
@@ -262,6 +262,12 @@
extra
:
extra
:
attrs
:
[
bool use_mkldnn = false
]
attrs
:
[
bool use_mkldnn = false
]
-
op
:
bilinear_tensor_product
inputs
:
{
x
:
X
,
y
:
Y
,
weight
:
Weight
,
bias
:
Bias
}
outputs
:
{
out
:
Out
}
-
op
:
bitwise_and
-
op
:
bitwise_and
inputs
:
inputs
:
{
x
:
X
,
y
:
Y
}
{
x
:
X
,
y
:
Y
}
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
90c3bddf
...
@@ -218,6 +218,16 @@
...
@@ -218,6 +218,16 @@
data_transform
:
data_transform
:
skip_transform
:
out_size, size_tensor, scale_tensor
skip_transform
:
out_size, size_tensor, scale_tensor
-
op
:
bilinear_tensor_product
args
:
(Tensor x, Tensor y, Tensor weight, Tensor bias)
output
:
Tensor
infer_meta
:
func
:
BilinearInferMeta
kernel
:
func
:
bilinear
optional
:
bias
backward
:
bilinear_tensor_product_grad
-
op
:
bitwise_and
-
op
:
bitwise_and
args
:
(Tensor x, Tensor y)
args
:
(Tensor x, Tensor y)
output
:
Tensor(out)
output
:
Tensor(out)
...
...
paddle/phi/ops/compat/bilinear_tensor_product_sig.cc
已删除
100644 → 0
浏览文件 @
3ee2b237
// 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
BilinearTensorProductOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"bilinear"
,
{
"X"
,
"Y"
,
"Weight"
,
"Bias"
},
{},
{
"Out"
});
}
KernelSignature
BilinearTensorProductGradOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"bilinear_grad"
,
{
"X"
,
"Y"
,
"Weight"
,
"Out@GRAD"
},
{},
{
"X@GRAD"
,
"Y@GRAD"
,
"Weight@GRAD"
,
"Bias@GRAD"
});
}
}
// namespace phi
PD_REGISTER_ARG_MAPPING_FN
(
bilinear_tensor_product
,
phi
::
BilinearTensorProductOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
bilinear_tensor_product_grad
,
phi
::
BilinearTensorProductGradOpArgumentMapping
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录