Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
12bf046b
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
12bf046b
编写于
8月 18, 2021
作者:
W
wawltor
提交者:
GitHub
8月 18, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the safe check for the some ops (#34978)
上级
52a7b0c4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
49 addition
and
7 deletion
+49
-7
paddle/fluid/operators/diag_embed_op.cc
paddle/fluid/operators/diag_embed_op.cc
+20
-6
paddle/fluid/operators/matmul_op.cc
paddle/fluid/operators/matmul_op.cc
+6
-0
paddle/fluid/operators/matmul_v2_op.cc
paddle/fluid/operators/matmul_v2_op.cc
+8
-0
paddle/fluid/operators/metrics/auc_op.cc
paddle/fluid/operators/metrics/auc_op.cc
+15
-1
未找到文件。
paddle/fluid/operators/diag_embed_op.cc
浏览文件 @
12bf046b
...
...
@@ -36,22 +36,36 @@ class DiagEmbedOp : public framework::OperatorWithKernel {
auto
x_dims
=
ctx
->
GetInputDim
(
"Input"
);
int
dim1_
=
dim1
<
0
?
x_dims
.
size
()
+
dim1
+
1
:
dim1
;
int
dim2_
=
dim2
<
0
?
x_dims
.
size
()
+
dim2
+
1
:
dim2
;
int
offset_
=
std
::
abs
(
offset
);
PADDLE_ENFORCE_GE
(
dim1
,
-
(
x_dims
.
size
()
+
1
),
platform
::
errors
::
OutOfRange
(
"Dim1 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld)."
,
-
(
x_dims
.
size
()
+
1
),
x_dims
.
size
(),
dim1
));
PADDLE_ENFORCE_LE
(
dim1
_
,
x_dims
.
size
(),
dim1
,
x_dims
.
size
(),
platform
::
errors
::
OutOfRange
(
"Dim1 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld)."
,
-
(
x_dims
.
size
()
+
1
),
x_dims
.
size
(),
dim1
));
PADDLE_ENFORCE_GE
(
dim2
,
-
(
x_dims
.
size
()
+
1
),
platform
::
errors
::
OutOfRange
(
"Dim2 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld)."
,
-
(
x_dims
.
size
()
+
1
),
x_dims
.
size
(),
dim2
));
PADDLE_ENFORCE_LE
(
dim2
_
,
x_dims
.
size
(),
dim2
,
x_dims
.
size
(),
platform
::
errors
::
OutOfRange
(
"Dim2 is out of range (expected to be in range of [%ld, "
"%ld], but got %ld)."
,
-
(
x_dims
.
size
()
+
1
),
x_dims
.
size
(),
dim2
));
int
dim1_
=
dim1
<
0
?
x_dims
.
size
()
+
dim1
+
1
:
dim1
;
int
dim2_
=
dim2
<
0
?
x_dims
.
size
()
+
dim2
+
1
:
dim2
;
int
offset_
=
std
::
abs
(
offset
);
PADDLE_ENFORCE_NE
(
dim1_
,
dim2_
,
platform
::
errors
::
InvalidArgument
(
"diagonal dimensions should not be identical "
...
...
paddle/fluid/operators/matmul_op.cc
浏览文件 @
12bf046b
...
...
@@ -330,6 +330,12 @@ framework::DDim GetDimForInput(const framework::InferShapeContext &ctx,
auto
axis
=
ctx
.
Attrs
().
Get
<
std
::
vector
<
int
>>
(
"fused_transpose_"
+
input_name
);
auto
dim
=
ctx
.
GetInputDim
(
input_name
);
PADDLE_ENFORCE_GT
(
dim
.
size
(),
0
,
platform
::
errors
::
InvalidArgument
(
"The Input(%s) has not been initialized properly. The "
"shape of Input(%s) = [%s]."
,
dim
));
if
(
!
shape
.
empty
()
&&
!
axis
.
empty
())
{
PADDLE_ENFORCE_GE
(
shape
.
size
(),
2
,
...
...
paddle/fluid/operators/matmul_v2_op.cc
浏览文件 @
12bf046b
...
...
@@ -35,6 +35,14 @@ class MatMulV2Op : public framework::OperatorWithKernel {
paddle
::
framework
::
vectorize
(
ctx
->
GetInputDim
(
"Y"
));
auto
ndims_x
=
dims_x
.
size
();
auto
ndims_y
=
dims_y
.
size
();
PADDLE_ENFORCE_GT
(
ndims_x
,
0
,
platform
::
errors
::
InvalidArgument
(
"The Input(X) dims size must be greater than 0,"
" but reviced dims size is 0. "
));
PADDLE_ENFORCE_GT
(
ndims_y
,
0
,
platform
::
errors
::
InvalidArgument
(
"The Input(Y) dims size must be greater than 0,"
" but reviced dims size is 0. "
));
bool
x_broadcasted
=
false
,
y_broadcasted
=
false
;
if
(
ndims_x
==
1
)
{
...
...
paddle/fluid/operators/metrics/auc_op.cc
浏览文件 @
12bf046b
...
...
@@ -25,7 +25,21 @@ class AucOp : public framework::OperatorWithKernel {
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"Predict"
),
"Input"
,
"Predict"
,
"Auc"
);
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"Label"
),
"Input"
,
"Label"
,
"Auc"
);
auto
predict_width
=
ctx
->
GetInputDim
(
"Predict"
)[
1
];
auto
predict_dims
=
ctx
->
GetInputDim
(
"Predict"
);
auto
label_dims
=
ctx
->
GetInputDim
(
"Label"
);
auto
predict_width
=
predict_dims
[
1
];
PADDLE_ENFORCE_NE
(
framework
::
product
(
predict_dims
),
0
,
platform
::
errors
::
InvalidArgument
(
"The Input(Predict) has not been initialized properly. The "
"shape of Input(Predict) = [%s], the shape can not involes 0."
,
predict_dims
));
PADDLE_ENFORCE_NE
(
framework
::
product
(
label_dims
),
0
,
platform
::
errors
::
InvalidArgument
(
"The Input(Label) has not been initialized properly. The "
"shape of Input(Label) = [%s], the shape can not involes 0."
,
label_dims
));
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_LE
(
predict_width
,
2
,
platform
::
errors
::
InvalidArgument
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录