Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
ea2c4987
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看板
未验证
提交
ea2c4987
编写于
5月 14, 2020
作者:
R
ruri
提交者:
GitHub
5月 14, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix err message (#24507)
* fix error message, test=develop
上级
4ec72876
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
31 addition
and
13 deletion
+31
-13
paddle/fluid/operators/pixel_shuffle_op.cc
paddle/fluid/operators/pixel_shuffle_op.cc
+30
-13
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+1
-0
未找到文件。
paddle/fluid/operators/pixel_shuffle_op.cc
浏览文件 @
ea2c4987
...
...
@@ -20,17 +20,27 @@ class PixelShuffleOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
"X"
),
"Input(X) of PixelShuffleOp should not be null."
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
"Out"
),
"Output(Out) of PixelShuffleOp should not be null."
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
"X"
),
true
,
platform
::
errors
::
NotFound
(
"Input(X) of PixelShuffleOp should not be null."
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
"Out"
),
true
,
platform
::
errors
::
NotFound
(
"Output(Out) of PixelShuffleOp should not be null."
));
auto
input_dims
=
ctx
->
GetInputDim
(
"X"
);
PADDLE_ENFORCE
(
input_dims
.
size
()
==
4
,
"The layout of input is NCHW."
);
PADDLE_ENFORCE_EQ
(
input_dims
.
size
(),
4
,
platform
::
errors
::
InvalidArgument
(
"Input should be a 4-D tensor of format [N, C, H, W], but got %u."
,
input_dims
.
size
()));
auto
upscale_factor
=
ctx
->
Attrs
().
Get
<
int
>
(
"upscale_factor"
);
PADDLE_ENFORCE
(
input_dims
[
1
]
%
(
upscale_factor
*
upscale_factor
)
==
0
,
"Upscale_factor should devide the number of channel"
);
PADDLE_ENFORCE_EQ
(
input_dims
[
1
]
%
(
upscale_factor
*
upscale_factor
),
0
,
platform
::
errors
::
InvalidArgument
(
"The square of upscale_factor[%u] should divide the "
"number of channel[%u]"
,
input_dims
[
1
],
upscale_factor
*
upscale_factor
));
auto
output_dims
=
input_dims
;
output_dims
[
0
]
=
input_dims
[
0
];
...
...
@@ -57,7 +67,8 @@ class PixelShuffleOpMaker : public framework::OpProtoAndCheckerMaker {
.
SetDefault
(
1
)
.
AddCustomChecker
([](
const
int
&
upscale_factor
)
{
PADDLE_ENFORCE_GE
(
upscale_factor
,
1
,
"upscale_factor should be larger than 0."
);
platform
::
errors
::
InvalidArgument
(
"upscale_factor should be larger than 0."
));
});
AddComment
(
R"DOC(
...
...
@@ -95,13 +106,19 @@ class PixelShuffleGradOp : public framework::OperatorWithKernel {
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
PADDLE_ENFORCE
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
"Input(Out@Grad) should not be null"
);
PADDLE_ENFORCE
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)),
"Output(X@Grad) should not be null"
);
PADDLE_ENFORCE_EQ
(
ctx
->
HasInput
(
framework
::
GradVarName
(
"Out"
)),
true
,
platform
::
errors
::
NotFound
(
"Input(Out@Grad) should not be null"
));
PADDLE_ENFORCE_EQ
(
ctx
->
HasOutput
(
framework
::
GradVarName
(
"X"
)),
true
,
platform
::
errors
::
NotFound
(
"Output(X@Grad) should not be null"
));
auto
do_dims
=
ctx
->
GetInputDim
(
framework
::
GradVarName
(
"Out"
));
PADDLE_ENFORCE
(
do_dims
.
size
()
==
4
,
"The layout of input is NCHW."
);
PADDLE_ENFORCE_EQ
(
do_dims
.
size
(),
4
,
platform
::
errors
::
InvalidArgument
(
"Input should be a 4-D tensor of format [N, C, H, W], but got %u."
,
do_dims
.
size
()));
auto
upscale_factor
=
ctx
->
Attrs
().
Get
<
int
>
(
"upscale_factor"
);
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
ea2c4987
...
...
@@ -13452,6 +13452,7 @@ def pixel_shuffle(x, upscale_factor):
"""
check_variable_and_dtype(x, 'x', ['float32', 'float64'], 'pixel_shuffle')
helper = LayerHelper("pixel_shuffle", **locals())
out = helper.create_variable_for_type_inference(dtype=x.dtype)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录