Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4f33f44b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
4f33f44b
编写于
5月 10, 2023
作者:
张
张春乔
提交者:
GitHub
5月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[static op generation] lstsq (#53290)
上级
7f39bcd1
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
27 addition
and
133 deletion
+27
-133
paddle/fluid/operators/lstsq_op.cc
paddle/fluid/operators/lstsq_op.cc
+0
-96
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
+10
-0
paddle/phi/api/yaml/op_version.yaml
paddle/phi/api/yaml/op_version.yaml
+7
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+10
-0
paddle/phi/ops/compat/lstsq_sig.cc
paddle/phi/ops/compat/lstsq_sig.cc
+0
-28
未找到文件。
paddle/fluid/operators/lstsq_op.cc
已删除
100644 → 0
浏览文件 @
7f39bcd1
// Copyright (c) 2021 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/fluid/framework/op_version_registry.h"
#include "paddle/phi/infermeta/binary.h"
namespace
paddle
{
namespace
operators
{
class
LstsqOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
protected:
// The output of lstsq is always complex-valued even for real-valued inputs
phi
::
KernelKey
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
dtype
=
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"X"
);
if
(
dtype
!=
framework
::
proto
::
VarType
::
FP32
&&
dtype
!=
framework
::
proto
::
VarType
::
FP64
)
{
PADDLE_THROW
(
platform
::
errors
::
InvalidArgument
(
"unsupported data type: %s!"
,
dtype
));
}
return
phi
::
KernelKey
(
dtype
,
ctx
.
GetPlace
());
}
};
class
LstsqOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"X"
,
"(Tensor), A real-valued tensor with shape (*, m, n). "
"The accepted datatype is one of float32, float64"
);
AddInput
(
"Y"
,
"(Tensor), A real-valued tensor with shape (*, m, k). "
"The accepted datatype is one of float32, float64"
);
AddAttr
<
float
>
(
"rcond"
,
"(float, default 0.0), A float value used to determine the effective "
"rank of A."
)
.
SetDefault
(
0.0
f
);
AddAttr
<
std
::
string
>
(
"driver"
,
"(string, default
\"
gels
\"
). "
"name of the LAPACK method to be used."
)
.
SetDefault
(
"gels"
);
AddOutput
(
"Solution"
,
"(Tensor), The output Solution tensor with shape (*, n, k)."
);
AddOutput
(
"Residuals"
,
"(Tensor), The output Residuals tensor with shape (*, k)."
)
.
AsDispensable
();
AddOutput
(
"Rank"
,
"(Tensor), The output Rank tensor with shape (*)."
);
AddOutput
(
"SingularValues"
,
"(Tensor), The output SingularValues tensor with shape (*, min(m,n))."
);
AddComment
(
R"DOC(
Lstsq Operator.
This API processes Lstsq functor for general matrices.
)DOC"
);
}
};
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
DECLARE_INFER_SHAPE_FUNCTOR
(
lstsq
,
LstsqInferShapeFunctor
,
PD_INFER_META
(
phi
::
LstsqInferMeta
));
REGISTER_OPERATOR
(
lstsq
,
ops
::
LstsqOp
,
ops
::
LstsqOpMaker
,
LstsqInferShapeFunctor
);
REGISTER_OP_VERSION
(
lstsq
).
AddCheckpoint
(
R"ROC(
Upgrade lstsq, add 1 outputs [Residuals].
)ROC"
,
paddle
::
framework
::
compatible
::
OpVersionDesc
().
NewOutput
(
"Residuals"
,
"Output tensor of lstsq operator, "
"meaning the squared residuals of the calculated solutions."
));
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
4f33f44b
...
...
@@ -669,15 +669,6 @@
func
:
logsumexp
backward
:
logsumexp_grad
-
op
:
lstsq
args
:
(Tensor x, Tensor y, Scalar rcond, str driver)
output
:
Tensor(solution), Tensor(residuals), Tensor(rank), Tensor(singular_values)
infer_meta
:
func
:
LstsqInferMeta
kernel
:
func
:
lstsq
data_type
:
x
-
op
:
matmul
args
:
(Tensor x, Tensor y, bool transpose_x =
false
, bool transpose_y =
false
)
output
:
Tensor
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
4f33f44b
...
...
@@ -1415,6 +1415,16 @@
extra
:
attrs
:
[
bool use_mkldnn = false
,
bool is_test = false
]
-
op
:
lstsq
inputs
:
{
x
:
X
,
y
:
Y
}
outputs
:
{
solution
:
Solution
,
residuals
:
Residuals
,
rank
:
Rank
,
singular_values
:
SingularValues
}
scalar
:
rcond
:
data_type
:
float
support_tensor
:
true
-
op
:
lu_unpack
backward
:
lu_unpack_grad
inputs
:
...
...
paddle/phi/api/yaml/op_version.yaml
浏览文件 @
4f33f44b
...
...
@@ -200,6 +200,13 @@
comment
:
In order to change output data type
default
:
5
-
op
:
lstsq
version
:
-
checkpoint
:
Upgrade lstsq, add 1 outputs [Residuals].
action
:
-
add_output
:
Residuals
comment
:
Output tensor of lstsq operator, meaning the squared residuals of the calculated solutions.
-
op
:
matrix_nms
version
:
-
checkpoint
:
Upgrade matrix_nms, add a new output [RoisNum].
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
4f33f44b
...
...
@@ -1231,6 +1231,16 @@
func
:
logsigmoid
backward
:
logsigmoid_grad
-
op
:
lstsq
args
:
(Tensor x, Tensor y, Scalar rcond=0.0f, str driver="gels")
output
:
Tensor(solution), Tensor(residuals), Tensor(rank), Tensor(singular_values)
infer_meta
:
func
:
LstsqInferMeta
kernel
:
func
:
lstsq
data_type
:
x
optional
:
residuals
-
op
:
lu
args
:
(Tensor x, bool pivot =
true
)
output
:
Tensor(out), Tensor(pivots), Tensor(infos)
...
...
paddle/phi/ops/compat/lstsq_sig.cc
已删除
100644 → 0
浏览文件 @
7f39bcd1
// 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
LstsqOpArgumentMapping
(
const
ArgumentMappingContext
&
ctx
)
{
return
KernelSignature
(
"lstsq"
,
{
"X"
,
"Y"
},
{
"rcond"
,
"driver"
},
{
"Solution"
,
"Residuals"
,
"Rank"
,
"SingularValues"
});
}
}
// namespace phi
PD_REGISTER_ARG_MAPPING_FN
(
lstsq
,
phi
::
LstsqOpArgumentMapping
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录