Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
75280d36
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
75280d36
编写于
3月 01, 2022
作者:
C
chentianyu03
提交者:
GitHub
3月 01, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove dot infershape (#39945)
上级
4149cabe
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
9 addition
and
46 deletion
+9
-46
paddle/fluid/operators/dot_op.cc
paddle/fluid/operators/dot_op.cc
+9
-46
未找到文件。
paddle/fluid/operators/dot_op.cc
浏览文件 @
75280d36
...
...
@@ -14,6 +14,10 @@
#include "paddle/fluid/operators/dot_op.h"
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/binary.h"
namespace
paddle
{
namespace
operators
{
...
...
@@ -21,51 +25,6 @@ class DotOp : public framework::OperatorWithKernel {
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE_EQ
(
true
,
ctx
->
HasInput
(
"X"
),
platform
::
errors
::
PreconditionNotMet
(
"Input(X) of DotOp should not be null."
));
PADDLE_ENFORCE_EQ
(
true
,
ctx
->
HasInput
(
"Y"
),
platform
::
errors
::
PreconditionNotMet
(
"Input(Y) of DotOp should not be null."
));
PADDLE_ENFORCE_EQ
(
true
,
ctx
->
HasOutput
(
"Out"
),
platform
::
errors
::
PreconditionNotMet
(
"Output(Out) of DotOp should not be null."
));
auto
x_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
x_rank
=
static_cast
<
size_t
>
(
x_dims
.
size
());
PADDLE_ENFORCE_EQ
(
true
,
1
==
x_rank
||
2
==
x_rank
,
platform
::
errors
::
PreconditionNotMet
(
"ShapeError: The dimensions of input tensor X (%s) "
"should be 1 or 2"
,
x_dims
.
to_str
()));
auto
y_dims
=
ctx
->
GetInputDim
(
"Y"
);
PADDLE_ENFORCE_EQ
(
true
,
x_rank
==
(
size_t
)
y_dims
.
size
(),
platform
::
errors
::
PreconditionNotMet
(
"ShapeError: The shape of input tensor Y: %s should match with "
"input tenosr X: %s"
,
y_dims
.
to_str
(),
x_dims
.
to_str
()));
bool
shape_match
=
true
;
for
(
size_t
i
=
0
;
i
<
x_rank
;
++
i
)
{
if
(
x_dims
[
i
]
!=
y_dims
[
i
])
{
shape_match
=
false
;
break
;
}
}
PADDLE_ENFORCE_EQ
(
true
,
shape_match
,
platform
::
errors
::
PreconditionNotMet
(
"ShapeError: The shape of input tensor X: %s should "
"be exactly the same "
"with input tensor Y: %s"
,
x_dims
.
to_str
(),
y_dims
.
to_str
()));
auto
dims
=
vectorize
(
x_dims
);
dims
[
dims
.
size
()
-
1
]
=
1
;
ctx
->
SetOutputDim
(
"Out"
,
phi
::
make_ddim
(
dims
));
}
framework
::
OpKernelType
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
return
framework
::
OpKernelType
(
...
...
@@ -142,9 +101,13 @@ class DotOpGradMaker : public framework::SingleGradOpMaker<T> {
namespace
ops
=
paddle
::
operators
;
DELCARE_INFER_SHAPE_FUNCTOR
(
dot
,
DotInferShapeFunctor
,
PT_INFER_META
(
phi
::
DotInferMeta
));
REGISTER_OPERATOR
(
dot
,
ops
::
DotOp
,
ops
::
DotOpMaker
,
ops
::
DotOpGradMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
DotOpGradMaker
<
paddle
::
imperative
::
OpBase
>
);
ops
::
DotOpGradMaker
<
paddle
::
imperative
::
OpBase
>
,
DotInferShapeFunctor
);
REGISTER_OPERATOR
(
dot_grad
,
ops
::
DotGradOp
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录