Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
2644cb81
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看板
未验证
提交
2644cb81
编写于
5月 14, 2020
作者:
Y
Yang Zhang
提交者:
GitHub
5月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove extraneous comma in error messages (#24478)
which messes up the formatting test=develop
上级
05c9642d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
71 deletion
+73
-71
paddle/fluid/operators/conv_shift_op.cc
paddle/fluid/operators/conv_shift_op.cc
+13
-14
paddle/fluid/operators/sample_logits_op.cc
paddle/fluid/operators/sample_logits_op.cc
+8
-8
paddle/fluid/operators/sample_logits_op.h
paddle/fluid/operators/sample_logits_op.h
+20
-20
paddle/fluid/operators/squared_l2_distance_op.cc
paddle/fluid/operators/squared_l2_distance_op.cc
+32
-29
未找到文件。
paddle/fluid/operators/conv_shift_op.cc
浏览文件 @
2644cb81
...
@@ -38,24 +38,24 @@ class ConvShiftOp : public framework::OperatorWithKernel {
...
@@ -38,24 +38,24 @@ class ConvShiftOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
x_dims
.
size
(),
2
,
x_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X)'s dimensions of ConvShiftOp should be 2."
"Input(X)'s dimensions of ConvShiftOp should be 2.
"
"But received X's shape = [%s] and the dimension is %d."
,
"But received X's shape = [%s] and the dimension is %d."
,
x_dims
,
x_dims
.
size
()));
x_dims
,
x_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
y_dims
.
size
(),
2
,
y_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(Y)'s dimensions of ConvShiftOp should be 2.
"
,
"Input(Y)'s dimensions of ConvShiftOp should be 2.
"
"But received Y's shape = [%s] and the dimension is %d."
,
y_dims
,
"But received Y's shape = [%s] and the dimension is %d."
,
y_dims
.
size
()));
y_dims
,
y_dims
.
size
()));
if
(
ctx
->
IsRuntime
()
||
(
x_dims
[
0
]
>
0
&&
y_dims
[
0
]
>
0
))
if
(
ctx
->
IsRuntime
()
||
(
x_dims
[
0
]
>
0
&&
y_dims
[
0
]
>
0
))
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
x_dims
[
0
],
y_dims
[
0
],
x_dims
[
0
],
y_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The first dimension of Input(X) and Input(Y) of ConvShiftOp "
,
"The first dimension of Input(X) and Input(Y) of ConvShiftOp "
"should be equal.
"
,
"should be equal.
"
"But received X's shape = [%s], Y's shape = [%s],
"
,
"But received X's shape = [%s], Y's shape = [%s],
"
"and the first dimensions are %d and %d respectively."
,
x_dims
,
"and the first dimensions are %d and %d respectively."
,
y_dims
,
x_dims
[
0
],
y_dims
[
0
]));
x_dims
,
y_dims
,
x_dims
[
0
],
y_dims
[
0
]));
if
(
ctx
->
IsRuntime
()
||
y_dims
[
1
]
>
0
)
if
(
ctx
->
IsRuntime
()
||
y_dims
[
1
]
>
0
)
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
y_dims
[
1
]
%
2
,
1
,
y_dims
[
1
]
%
2
,
1
,
...
@@ -68,11 +68,10 @@ class ConvShiftOp : public framework::OperatorWithKernel {
...
@@ -68,11 +68,10 @@ class ConvShiftOp : public framework::OperatorWithKernel {
y_dims
[
1
],
x_dims
[
1
],
y_dims
[
1
],
x_dims
[
1
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The second dimension of Input(Y) of ConvShiftOp should be less "
"The second dimension of Input(Y) of ConvShiftOp should be less "
"than or "
"than or equal to the 2nd dimension of Input(X)."
"equal to the 2nd dimension of Input(X)."
"But received X's shape = [%s], Y's shape = [%s], "
"But received X's shape = [%s], Y's shape = [%s],"
,
"and the second dimensions are %d and %d respectively."
,
"and the second dimensions are %d and %d respectively."
,
x_dims
,
x_dims
,
y_dims
,
x_dims
[
1
],
y_dims
[
1
]));
y_dims
,
x_dims
[
1
],
y_dims
[
1
]));
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareDim
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
}
}
...
...
paddle/fluid/operators/sample_logits_op.cc
浏览文件 @
2644cb81
...
@@ -135,12 +135,12 @@ class SampleLogitsOp : public framework::OperatorWithKernel {
...
@@ -135,12 +135,12 @@ class SampleLogitsOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
logits_dims
.
size
(),
2UL
,
PADDLE_ENFORCE_EQ
(
logits_dims
.
size
(),
2UL
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(Logits) of SampleLogitsOp should be 2D.
"
,
"Input(Logits) of SampleLogitsOp should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
logits_dims
,
logits_dims
.
size
()));
logits_dims
,
logits_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
labels_dims
.
size
(),
2UL
,
PADDLE_ENFORCE_EQ
(
labels_dims
.
size
(),
2UL
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(Labels) of SampleLogitsOp should be 2D.
"
,
"Input(Labels) of SampleLogitsOp should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
labels_dims
,
labels_dims
.
size
()));
labels_dims
,
labels_dims
.
size
()));
...
@@ -198,15 +198,15 @@ class SampleLogitsOpGrad : public framework::OperatorWithKernel {
...
@@ -198,15 +198,15 @@ class SampleLogitsOpGrad : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
logits_dims
.
size
(),
2UL
,
logits_dims
.
size
(),
2UL
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(LogitsDim) of SampleLogitsOpGrad should be 2D.
"
,
"Input(LogitsDim) of SampleLogitsOpGrad should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
logits_dims
,
"But received shape = [%s] and dimension is %d."
,
logits_dims
.
size
()));
logits_dims
,
logits_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
labels_dims
.
size
(),
2UL
,
labels_dims
.
size
(),
2UL
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(LabelsDim) of SampleLogitsOpGrad should be 2D.
"
,
"Input(LabelsDim) of SampleLogitsOpGrad should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
labels_dims
,
"But received shape = [%s] and dimension is %d."
,
labels_dims
.
size
()));
labels_dims
,
labels_dims
.
size
()));
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Logits"
),
logits_dims
);
ctx
->
SetOutputDim
(
framework
::
GradVarName
(
"Logits"
),
logits_dims
);
}
}
...
...
paddle/fluid/operators/sample_logits_op.h
浏览文件 @
2644cb81
...
@@ -59,27 +59,27 @@ static void CPUTakeAlongD1(const platform::DeviceContext& ctx,
...
@@ -59,27 +59,27 @@ static void CPUTakeAlongD1(const platform::DeviceContext& ctx,
const
auto
idx_dims
=
index
.
dims
();
const
auto
idx_dims
=
index
.
dims
();
PADDLE_ENFORCE_EQ
(
idx_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
idx_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"index of CPUTakeAlongD1 should be 2D.
"
,
"index of CPUTakeAlongD1 should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
idx_dims
,
idx_dims
.
size
()));
idx_dims
,
idx_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
array_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
array_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"array of CPUTakeAlongD1 should be 2D.
"
,
"array of CPUTakeAlongD1 should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
array_dims
,
array_dims
.
size
()));
array_dims
,
array_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
idx_dims
[
0
],
array_dims
[
0
],
PADDLE_ENFORCE_EQ
(
idx_dims
[
0
],
array_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The first dimension of index and array of "
,
"The first dimension of index and array of "
"CPUTakeAlongD1 should be equal.
"
,
"CPUTakeAlongD1 should be equal.
"
"But received index shape = [%s], array shape = [%s],
"
,
"But received index shape = [%s], array shape = [%s],
"
"and the first dimensions are %d and %d."
,
idx_dims
,
"and the first dimensions are %d and %d."
,
array_dims
,
idx_dims
[
0
],
array_dims
[
0
]));
idx_dims
,
array_dims
,
idx_dims
[
0
],
array_dims
[
0
]));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
idx_dims
,
value
->
dims
(),
idx_dims
,
value
->
dims
(),
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"index and array of CPUTakeAlongD1 should have
"
,
"the same shape."
,
"index and array of CPUTakeAlongD1 should have
the same shape. "
"But received index shape = [%s], array shape = [%s]."
,
idx_dims
,
"But received index shape = [%s], array shape = [%s]."
,
value
->
dims
()));
idx_dims
,
value
->
dims
()));
// UNDERSTAND: no allocations here
// UNDERSTAND: no allocations here
const
T
*
p_array
=
array
.
data
<
T
>
();
const
T
*
p_array
=
array
.
data
<
T
>
();
...
@@ -119,27 +119,27 @@ static void CPUPutAlongD1(const platform::DeviceContext& ctx,
...
@@ -119,27 +119,27 @@ static void CPUPutAlongD1(const platform::DeviceContext& ctx,
auto
idx_dims
=
index
.
dims
();
auto
idx_dims
=
index
.
dims
();
PADDLE_ENFORCE_EQ
(
idx_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
idx_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"index of CPUPutAlongD1 should be 2D.
"
,
"index of CPUPutAlongD1 should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
idx_dims
,
idx_dims
.
size
()));
idx_dims
,
idx_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
array_dims
.
size
(),
2
,
PADDLE_ENFORCE_EQ
(
array_dims
.
size
(),
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"array of CPUPutAlongD1 should be 2D.
"
,
"array of CPUPutAlongD1 should be 2D.
"
"But received shape = [%s] and dimension is %d."
,
"But received shape = [%s] and dimension is %d."
,
array_dims
,
array_dims
.
size
()));
array_dims
,
array_dims
.
size
()));
PADDLE_ENFORCE_EQ
(
idx_dims
[
0
],
array_dims
[
0
],
PADDLE_ENFORCE_EQ
(
idx_dims
[
0
],
array_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"The first dimension of index and array of "
,
"The first dimension of index and array of "
"CPUPutAlongD1 should be equal.
"
,
"CPUPutAlongD1 should be equal.
"
"But received index shape = [%s], array shape = [%s],
"
,
"But received index shape = [%s], array shape = [%s],
"
"and the first dimensions are %d and %d."
,
idx_dims
,
"and the first dimensions are %d and %d."
,
array_dims
,
idx_dims
[
0
],
array_dims
[
0
]));
idx_dims
,
array_dims
,
idx_dims
[
0
],
array_dims
[
0
]));
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
idx_dims
,
value
.
dims
(),
idx_dims
,
value
.
dims
(),
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"index and array of CPUPutAlongD1 should have
"
,
"the same shape."
,
"index and array of CPUPutAlongD1 should have
the same shape. "
"But received index shape = [%s], array shape = [%s]."
,
idx_dims
,
"But received index shape = [%s], array shape = [%s]."
,
value
.
dims
()));
idx_dims
,
value
.
dims
()));
// UNDERSTAND: no allocations here
// UNDERSTAND: no allocations here
T
*
p_array
=
array
->
data
<
T
>
();
T
*
p_array
=
array
->
data
<
T
>
();
...
...
paddle/fluid/operators/squared_l2_distance_op.cc
浏览文件 @
2644cb81
...
@@ -36,21 +36,22 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
...
@@ -36,21 +36,22 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
auto
x_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
x_dims
=
ctx
->
GetInputDim
(
"X"
);
auto
y_dims
=
ctx
->
GetInputDim
(
"Y"
);
auto
y_dims
=
ctx
->
GetInputDim
(
"Y"
);
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
framework
::
arity
(
x_dims
),
framework
::
arity
(
y_dims
),
framework
::
arity
(
x_dims
),
framework
::
arity
(
y_dims
),
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X) and Input(X) of SquaredL2DistanceOp should "
"Input(X) and Input(X) of SquaredL2DistanceOp should "
,
"have same dimensions. "
"have same dimensions."
,
"But received X's shape = [%s] and Y's shape = [%s], "
"But received X's shape = [%s] and Y's shape = [%s],
"
,
"the dimensions are %d and %d respectively
"
,
"the dimensions are %d and %d respectively"
,
x_dims
,
y_dims
,
x_dims
,
y_dims
,
framework
::
arity
(
x_dims
)
,
framework
::
arity
(
x_dims
),
framework
::
arity
(
y_dims
)));
framework
::
arity
(
y_dims
)));
int
rank
=
framework
::
arity
(
x_dims
);
int
rank
=
framework
::
arity
(
x_dims
);
PADDLE_ENFORCE_GE
(
PADDLE_ENFORCE_GE
(
rank
,
2
,
rank
,
2
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input dimensions of SquaredL2DistanceOp should be "
,
"at least 2."
,
"Input dimensions of SquaredL2DistanceOp should be at least 2."
"But received shape = [%s] and dimension is %d."
,
x_dims
,
rank
));
"But received shape = [%s] and dimension is %d."
,
x_dims
,
rank
));
bool
check
=
true
;
bool
check
=
true
;
if
((
!
ctx
->
IsRuntime
())
&&
if
((
!
ctx
->
IsRuntime
())
&&
(
framework
::
product
(
x_dims
)
<=
0
||
framework
::
product
(
y_dims
)
<=
0
))
{
(
framework
::
product
(
x_dims
)
<=
0
||
framework
::
product
(
y_dims
)
<=
0
))
{
...
@@ -60,11 +61,12 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
...
@@ -60,11 +61,12 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
product
(
x_dims
)
/
x_dims
[
0
],
product
(
y_dims
)
/
y_dims
[
0
],
product
(
x_dims
)
/
x_dims
[
0
],
product
(
y_dims
)
/
y_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input(X) and Input(Y) of SquaredL2DistanceOp should "
,
"Input(X) and Input(Y) of SquaredL2DistanceOp should "
"have same dimensions."
,
"have same dimensions."
"But received X's shape = [%s] and Y's shape = [%s]"
,
"But received X's shape = [%s] and Y's shape = [%s]"
", the products are %d and %d respectively"
,
x_dims
,
y_dims
,
", the products are %d and %d respectively"
,
product
(
x_dims
)
/
x_dims
[
0
],
product
(
y_dims
)
/
y_dims
[
0
]));
x_dims
,
y_dims
,
product
(
x_dims
)
/
x_dims
[
0
],
product
(
y_dims
)
/
y_dims
[
0
]));
}
}
check
=
true
;
check
=
true
;
if
((
!
ctx
->
IsRuntime
())
&&
(
y_dims
[
0
]
<=
0
||
x_dims
[
0
]
<=
0
))
{
if
((
!
ctx
->
IsRuntime
())
&&
(
y_dims
[
0
]
<=
0
||
x_dims
[
0
]
<=
0
))
{
...
@@ -74,11 +76,11 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
...
@@ -74,11 +76,11 @@ class SquaredL2DistanceOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
y_dims
[
0
]
==
1
||
y_dims
[
0
]
==
x_dims
[
0
],
true
,
y_dims
[
0
]
==
1
||
y_dims
[
0
]
==
x_dims
[
0
],
true
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"First dimension of Input(Y) of SquaredL2DistanceOp "
,
"First dimension of Input(Y) of SquaredL2DistanceOp "
"must be equal to 1
"
,
"or to first dimension of Input(X)."
,
"must be equal to 1
or to first dimension of Input(X)."
"But received X's shape = [%s] and Y's shape = [%s],"
,
"But received X's shape = [%s] and Y's shape = [%s],"
"the first dimensions are %d and %d respectively"
,
x_dims
,
y_dims
,
"the first dimensions are %d and %d respectively"
,
x_dims
[
0
],
y_dims
[
0
]));
x_dims
,
y_dims
,
x_dims
[
0
],
y_dims
[
0
]));
}
}
ctx
->
SetOutputDim
(
"sub_result"
,
{
x_dims
[
0
],
product
(
x_dims
)
/
x_dims
[
0
]});
ctx
->
SetOutputDim
(
"sub_result"
,
{
x_dims
[
0
],
product
(
x_dims
)
/
x_dims
[
0
]});
ctx
->
SetOutputDim
(
"Out"
,
{
x_dims
[
0
],
1
});
ctx
->
SetOutputDim
(
"Out"
,
{
x_dims
[
0
],
1
});
...
@@ -152,17 +154,18 @@ class SquaredL2DistanceGradOp : public framework::OperatorWithKernel {
...
@@ -152,17 +154,18 @@ class SquaredL2DistanceGradOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
out_dims
[
0
],
x_dims
[
0
],
out_dims
[
0
],
x_dims
[
0
],
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"First dimension of output gradient and Input(X) "
,
"First dimension of output gradient and Input(X) "
"of SquaredL2DistanceGradOp must be equal
"
,
"of SquaredL2DistanceGradOp must be equal
"
"But received X's shape = [%s] and grad's shape = [%s],
"
,
"But received X's shape = [%s] and grad's shape = [%s],
"
"the first dimensions are %d and %d respectively"
,
x_dims
,
"the first dimensions are %d and %d respectively"
,
out_dims
,
x_dims
[
0
],
out_dims
[
0
]));
x_dims
,
out_dims
,
x_dims
[
0
],
out_dims
[
0
]));
PADDLE_ENFORCE_EQ
(
out_dims
[
1
],
1
,
PADDLE_ENFORCE_EQ
(
out_dims
[
1
],
1
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Second dimension of output gradient of "
,
"Second dimension of output gradient of "
"SquaredL2DistanceGradOp must be 1."
"SquaredL2DistanceGradOp must be 1. "
"But received grad's shape = [%s],"
,
"But received grad's shape = [%s], "
"with first dimensions %d"
,
out_dims
,
out_dims
[
1
]));
"with second dimension %d"
,
out_dims
,
out_dims
[
1
]));
}
}
auto
x_grad_name
=
framework
::
GradVarName
(
"X"
);
auto
x_grad_name
=
framework
::
GradVarName
(
"X"
);
auto
y_grad_name
=
framework
::
GradVarName
(
"Y"
);
auto
y_grad_name
=
framework
::
GradVarName
(
"Y"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录