Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
19bb53fa
P
Paddle
项目概览
机器未来
/
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看板
未验证
提交
19bb53fa
编写于
4月 15, 2019
作者:
K
Kaipeng Deng
提交者:
GitHub
4月 15, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16850 from heavengate/fix_infer_shape
infer shape compatable -1. test=develop
上级
2de7f3cf
e590588a
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
29 addition
and
12 deletion
+29
-12
paddle/fluid/operators/grid_sampler_op.cc
paddle/fluid/operators/grid_sampler_op.cc
+6
-3
paddle/fluid/operators/interpolate_op.cc
paddle/fluid/operators/interpolate_op.cc
+6
-0
paddle/fluid/operators/kldiv_loss_op.cc
paddle/fluid/operators/kldiv_loss_op.cc
+4
-2
paddle/fluid/operators/spectral_norm_op.cc
paddle/fluid/operators/spectral_norm_op.cc
+13
-7
未找到文件。
paddle/fluid/operators/grid_sampler_op.cc
浏览文件 @
19bb53fa
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/operators/grid_sampler_op.h"
#include "paddle/fluid/operators/grid_sampler_op.h"
#include <memory>
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_registry.h"
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
#include "paddle/fluid/platform/cudnn_helper.h"
#include "paddle/fluid/platform/cudnn_helper.h"
...
@@ -40,10 +41,12 @@ class GridSampleOp : public framework::OperatorWithKernel {
...
@@ -40,10 +41,12 @@ class GridSampleOp : public framework::OperatorWithKernel {
"Input(X) of GridSampleOp should be 4-D Tensor."
);
"Input(X) of GridSampleOp should be 4-D Tensor."
);
PADDLE_ENFORCE
(
grid_dims
.
size
()
==
4
,
PADDLE_ENFORCE
(
grid_dims
.
size
()
==
4
,
"Input(Grid) of GridSampleOp should be 4-D Tensor."
);
"Input(Grid) of GridSampleOp should be 4-D Tensor."
);
if
(
ctx
->
IsRuntime
()
||
grid_dims
[
3
]
>
0
)
{
PADDLE_ENFORCE
(
grid_dims
[
3
]
==
2
,
"Input(Grid) dims[3] should be 2."
);
PADDLE_ENFORCE
(
grid_dims
[
3
]
==
2
,
"Input(Grid) dims[3] should be 2."
);
}
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
grid_dims
[
0
],
x_dims
[
0
],
PADDLE_ENFORCE_EQ
(
grid_dims
[
0
],
x_dims
[
0
],
"Input(X) and Input(Grid) dims[0] should be equal."
);
"Input(X) and Input(Grid) dims[0] should be equal."
);
if
(
ctx
->
IsRuntime
())
{
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
grid_dims
[
1
],
x_dims
[
2
],
grid_dims
[
1
],
x_dims
[
2
],
"Input(X) dims[2] and Input(Grid) dims[1] should be equal."
);
"Input(X) dims[2] and Input(Grid) dims[1] should be equal."
);
...
...
paddle/fluid/operators/interpolate_op.cc
浏览文件 @
19bb53fa
...
@@ -45,9 +45,14 @@ class InterpolateOp : public framework::OperatorWithKernel {
...
@@ -45,9 +45,14 @@ class InterpolateOp : public framework::OperatorWithKernel {
// round down
// round down
out_h
=
static_cast
<
int
>
(
dim_x
[
2
]
*
scale
);
out_h
=
static_cast
<
int
>
(
dim_x
[
2
]
*
scale
);
out_w
=
static_cast
<
int
>
(
dim_x
[
3
]
*
scale
);
out_w
=
static_cast
<
int
>
(
dim_x
[
3
]
*
scale
);
// protect when input shape is -1
out_h
=
out_h
>
0
?
out_h
:
-
1
;
out_w
=
out_w
>
0
?
out_w
:
-
1
;
}
else
{
}
else
{
out_h
=
ctx
->
Attrs
().
Get
<
int
>
(
"out_h"
);
out_h
=
ctx
->
Attrs
().
Get
<
int
>
(
"out_h"
);
out_w
=
ctx
->
Attrs
().
Get
<
int
>
(
"out_w"
);
out_w
=
ctx
->
Attrs
().
Get
<
int
>
(
"out_w"
);
PADDLE_ENFORCE_GT
(
out_h
,
0
,
"out_h should be greater than 0."
);
PADDLE_ENFORCE_GT
(
out_w
,
0
,
"out_w should be greater than 0."
);
}
}
if
(
ctx
->
HasInput
(
"OutSize"
)
&&
ctx
->
IsRuntime
())
{
if
(
ctx
->
HasInput
(
"OutSize"
)
&&
ctx
->
IsRuntime
())
{
...
@@ -58,6 +63,7 @@ class InterpolateOp : public framework::OperatorWithKernel {
...
@@ -58,6 +63,7 @@ class InterpolateOp : public framework::OperatorWithKernel {
ctx
->
ShareLoD
(
"X"
,
"Out"
);
ctx
->
ShareLoD
(
"X"
,
"Out"
);
return
;
return
;
}
}
std
::
vector
<
int64_t
>
dim_out
({
dim_x
[
0
],
dim_x
[
1
],
out_h
,
out_w
});
std
::
vector
<
int64_t
>
dim_out
({
dim_x
[
0
],
dim_x
[
1
],
out_h
,
out_w
});
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
dim_out
));
ctx
->
SetOutputDim
(
"Out"
,
framework
::
make_ddim
(
dim_out
));
}
}
...
...
paddle/fluid/operators/kldiv_loss_op.cc
浏览文件 @
19bb53fa
...
@@ -35,9 +35,11 @@ class KLDivLossOp : public framework::OperatorWithKernel {
...
@@ -35,9 +35,11 @@ class KLDivLossOp : public framework::OperatorWithKernel {
PADDLE_ENFORCE_EQ
(
dim_x
.
size
(),
dim_target
.
size
(),
PADDLE_ENFORCE_EQ
(
dim_x
.
size
(),
dim_target
.
size
(),
"Input(X) rank and Input(Target) rank should be same."
);
"Input(X) rank and Input(Target) rank should be same."
);
for
(
int
i
=
0
;
i
<
dim_x
.
size
();
i
++
)
{
for
(
int
i
=
0
;
i
<
dim_x
.
size
();
i
++
)
{
if
(
ctx
->
IsRuntime
()
||
(
dim_x
[
i
]
>
0
&&
dim_target
[
i
]
>
0
))
{
PADDLE_ENFORCE_EQ
(
dim_x
[
i
],
dim_target
[
i
],
PADDLE_ENFORCE_EQ
(
dim_x
[
i
],
dim_target
[
i
],
"Input(X) and Input(Target) should in same shape."
);
"Input(X) and Input(Target) should in same shape."
);
}
}
}
auto
reduction
=
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"reduction"
);
auto
reduction
=
ctx
->
Attrs
().
Get
<
std
::
string
>
(
"reduction"
);
...
...
paddle/fluid/operators/spectral_norm_op.cc
浏览文件 @
19bb53fa
...
@@ -56,13 +56,19 @@ class SpectralNormOp : public framework::OperatorWithKernel {
...
@@ -56,13 +56,19 @@ class SpectralNormOp : public framework::OperatorWithKernel {
}
}
auto
dim_u
=
ctx
->
GetInputDim
(
"U"
);
auto
dim_u
=
ctx
->
GetInputDim
(
"U"
);
auto
dim_v
=
ctx
->
GetInputDim
(
"V"
);
auto
dim_v
=
ctx
->
GetInputDim
(
"V"
);
if
(
ctx
->
IsRuntime
()
||
(
dim_u
[
0
]
>
0
&&
h
>
0
))
{
PADDLE_ENFORCE_EQ
(
dim_u
[
0
],
h
,
PADDLE_ENFORCE_EQ
(
dim_u
[
0
],
h
,
"Input(U) dims[0] should be equal to "
"Input(U) dims[0] should be equal to "
"Input(Weight) dims[Attr(dim)]"
);
"Input(Weight) dims[Attr(dim)]"
);
}
if
(
ctx
->
IsRuntime
()
||
(
dim_v
[
0
]
>
0
&&
w
>
0
))
{
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
dim_v
[
0
],
w
,
dim_v
[
0
],
w
,
"Input(V) dims[0] should be equal to "
"Input(V) dims[0] should be equal to "
"the product of Input(Weight) dims except dims[Attr(dim)]"
);
"the product of Input(Weight) dims except dims[Attr(dim)]"
);
}
ctx
->
SetOutputDim
(
"Out"
,
dim_weight
);
ctx
->
SetOutputDim
(
"Out"
,
dim_weight
);
ctx
->
ShareLoD
(
"Weight"
,
/*->*/
"Out"
);
ctx
->
ShareLoD
(
"Weight"
,
/*->*/
"Out"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录