Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
14499e83
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
14499e83
编写于
12月 30, 2021
作者:
Q
Qsingle
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the type error of pixel shuffle
add the test of dtype float
上级
d9a46ea4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
4 deletion
+30
-4
imperative/python/megengine/functional/nn.py
imperative/python/megengine/functional/nn.py
+3
-3
imperative/python/test/unit/functional/test_functional.py
imperative/python/test/unit/functional/test_functional.py
+27
-1
未找到文件。
imperative/python/megengine/functional/nn.py
浏览文件 @
14499e83
...
@@ -1889,7 +1889,7 @@ def pixel_shuffle(inp: Tensor, upscale_factor: int) -> Tensor:
...
@@ -1889,7 +1889,7 @@ def pixel_shuffle(inp: Tensor, upscale_factor: int) -> Tensor:
)
)
shape_1
=
(
shape_1
=
(
*
high_dim
,
*
high_dim
,
shape_ori
[
-
3
]
/
square
,
int
(
shape_ori
[
-
3
]
/
square
)
,
shape_ori
[
-
2
]
*
upscale_factor
,
shape_ori
[
-
2
]
*
upscale_factor
,
shape_ori
[
-
1
]
*
upscale_factor
,
shape_ori
[
-
1
]
*
upscale_factor
,
)
)
...
@@ -1898,8 +1898,8 @@ def pixel_shuffle(inp: Tensor, upscale_factor: int) -> Tensor:
...
@@ -1898,8 +1898,8 @@ def pixel_shuffle(inp: Tensor, upscale_factor: int) -> Tensor:
layerPixelShuffle
=
_get_layerPixelShuffle
(
_device
,
_dtype
,
dim_order
)
layerPixelShuffle
=
_get_layerPixelShuffle
(
_device
,
_dtype
,
dim_order
)
shape_0
=
convert_single_value
(
shape_0
,
d
type
=
inp
.
dtype
,
d
evice
=
inp
.
device
)
shape_0
=
convert_single_value
(
shape_0
,
device
=
inp
.
device
)
shape_1
=
convert_single_value
(
shape_1
,
d
type
=
inp
.
dtype
,
d
evice
=
inp
.
device
)
shape_1
=
convert_single_value
(
shape_1
,
device
=
inp
.
device
)
outvar
,
*
_
=
apply
(
layerPixelShuffle
(),
inp
,
shape_0
,
shape_1
)
outvar
,
*
_
=
apply
(
layerPixelShuffle
(),
inp
,
shape_0
,
shape_1
)
return
outvar
return
outvar
...
...
imperative/python/test/unit/functional/test_functional.py
浏览文件 @
14499e83
...
@@ -1218,30 +1218,49 @@ def test_pixel_shuffle():
...
@@ -1218,30 +1218,49 @@ def test_pixel_shuffle():
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
4
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
4
)
golden
=
pixel_shuffle
(
inp
,
4
)
golden
=
pixel_shuffle
(
inp
,
4
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
inp_float
=
np
.
float32
(
inp
)
out
=
F
.
pixel_shuffle
(
inp_float
,
2
)
golden
=
pixel_shuffle
(
inp_float
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
# ndim = 4
# ndim = 4
inp
=
np
.
arange
(
3
*
18
*
3
*
3
).
reshape
(
3
,
18
,
3
,
3
)
inp
=
np
.
arange
(
3
*
18
*
3
*
3
).
reshape
(
3
,
18
,
3
,
3
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
3
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
3
)
golden
=
pixel_shuffle
(
inp
,
3
)
golden
=
pixel_shuffle
(
inp
,
3
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
inp_float
=
np
.
float32
(
inp
)
out
=
F
.
pixel_shuffle
(
inp_float
,
2
)
golden
=
pixel_shuffle
(
inp_float
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
# ndim = 5
# ndim = 5
inp
=
np
.
arange
(
5
*
3
*
20
*
3
*
4
).
reshape
(
5
,
3
,
20
,
3
,
4
)
inp
=
np
.
arange
(
5
*
3
*
20
*
3
*
4
).
reshape
(
5
,
3
,
20
,
3
,
4
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
2
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
2
)
golden
=
pixel_shuffle
(
inp
,
2
)
golden
=
pixel_shuffle
(
inp
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
inp_float
=
np
.
float32
(
inp
)
out
=
F
.
pixel_shuffle
(
inp_float
,
2
)
golden
=
pixel_shuffle
(
inp_float
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
# ndim = 6
# ndim = 6
inp
=
np
.
arange
(
6
*
5
*
3
*
25
*
3
*
4
).
reshape
(
6
,
5
,
3
,
25
,
3
,
4
)
inp
=
np
.
arange
(
6
*
5
*
3
*
25
*
3
*
4
).
reshape
(
6
,
5
,
3
,
25
,
3
,
4
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
5
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
5
)
golden
=
pixel_shuffle
(
inp
,
5
)
golden
=
pixel_shuffle
(
inp
,
5
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
inp_float
=
np
.
float32
(
inp
)
out
=
F
.
pixel_shuffle
(
inp_float
,
2
)
golden
=
pixel_shuffle
(
inp_float
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
# ndim = 7
# ndim = 7
inp
=
np
.
arange
(
2
*
3
*
5
*
3
*
20
*
3
*
4
).
reshape
(
2
,
3
,
5
,
3
,
20
,
3
,
4
)
inp
=
np
.
arange
(
2
*
3
*
5
*
3
*
20
*
3
*
4
).
reshape
(
2
,
3
,
5
,
3
,
20
,
3
,
4
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
2
)
out
=
F
.
pixel_shuffle
(
tensor
(
inp
),
upscale_factor
=
2
)
golden
=
pixel_shuffle
(
inp
,
2
)
golden
=
pixel_shuffle
(
inp
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
inp_float
=
np
.
float32
(
inp
)
out
=
F
.
pixel_shuffle
(
inp_float
,
2
)
golden
=
pixel_shuffle
(
inp_float
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
@
pytest
.
mark
.
parametrize
(
"is_symbolic"
,
[
False
,
True
])
@
pytest
.
mark
.
parametrize
(
"is_symbolic"
,
[
False
,
True
])
...
@@ -1260,6 +1279,13 @@ def test_pixel_shuffle_symbolic(is_symbolic):
...
@@ -1260,6 +1279,13 @@ def test_pixel_shuffle_symbolic(is_symbolic):
if
is_symbolic
is
None
:
if
is_symbolic
is
None
:
break
break
inp
=
np
.
float32
(
inp
)
golden
=
pixel_shuffle
(
inp
,
2
)
for
_
in
range
(
3
):
out
=
fn
(
inp
,
2
)
np
.
testing
.
assert_equal
(
out
.
numpy
(),
golden
)
if
is_symbolic
is
None
:
break
def
test_set_conv2d_config
():
def
test_set_conv2d_config
():
"""check setting config by contextmanager is equal to manually converted result"""
"""check setting config by contextmanager is equal to manually converted result"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录