Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
ba99cb7b
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ba99cb7b
编写于
5月 13, 2020
作者:
J
jiangjinsheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
support vm for space_to_depth
上级
f7386722
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
119 addition
and
2 deletion
+119
-2
mindspore/ops/_op_impl/tbe/__init__.py
mindspore/ops/_op_impl/tbe/__init__.py
+2
-0
mindspore/ops/_op_impl/tbe/depth_to_space.py
mindspore/ops/_op_impl/tbe/depth_to_space.py
+46
-0
mindspore/ops/_op_impl/tbe/space_to_depth.py
mindspore/ops/_op_impl/tbe/space_to_depth.py
+46
-0
mindspore/ops/operations/array_ops.py
mindspore/ops/operations/array_ops.py
+0
-2
tests/ut/python/ops/test_array_ops.py
tests/ut/python/ops/test_array_ops.py
+25
-0
未找到文件。
mindspore/ops/_op_impl/tbe/__init__.py
浏览文件 @
ba99cb7b
...
...
@@ -164,6 +164,8 @@ from .avg_pool_grad import _avg_pool_grad_tbe
from
.ones_like
import
_ones_like_tbe
from
.batch_to_space
import
_batch_to_space_tbe
from
.space_to_batch
import
_space_to_batch_tbe
from
.depth_to_space
import
_depth_to_space_tbe
from
.space_to_depth
import
_space_to_depth_tbe
from
.floor
import
_floor_tbe
from
.log1p
import
_log1p_tbe
from
.resize_bilinear
import
_resize_bilinear_tbe
...
...
mindspore/ops/_op_impl/tbe/depth_to_space.py
0 → 100644
浏览文件 @
ba99cb7b
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""DepthToSpace op"""
from
mindspore.ops.op_info_register
import
op_info_register
,
TBERegOp
,
DataType
depth_to_space_op_info
=
TBERegOp
(
"DepthToSpace"
)
\
.
fusion_type
(
"OPAQUE"
)
\
.
async_flag
(
False
)
\
.
binfile_name
(
"depth_to_space.so"
)
\
.
compute_cost
(
10
)
\
.
kernel_name
(
"depth_to_space"
)
\
.
partial_flag
(
True
)
\
.
attr
(
"block_size"
,
"required"
,
"int"
,
"all"
)
\
.
attr
(
"data_format"
,
"optional"
,
"str"
,
"all"
)
\
.
input
(
0
,
"x"
,
False
,
"required"
,
"all"
)
\
.
output
(
0
,
"y"
,
False
,
"required"
,
"all"
)
\
.
dtype_format
(
DataType
.
F16_NHWC
,
DataType
.
F16_NHWC
)
\
.
dtype_format
(
DataType
.
F32_NHWC
,
DataType
.
F32_NHWC
)
\
.
dtype_format
(
DataType
.
I8_NHWC
,
DataType
.
I8_NHWC
)
\
.
dtype_format
(
DataType
.
I16_NHWC
,
DataType
.
I16_NHWC
)
\
.
dtype_format
(
DataType
.
I32_NHWC
,
DataType
.
I32_NHWC
)
\
.
dtype_format
(
DataType
.
I64_NHWC
,
DataType
.
I64_NHWC
)
\
.
dtype_format
(
DataType
.
U8_NHWC
,
DataType
.
U8_NHWC
)
\
.
dtype_format
(
DataType
.
U16_NHWC
,
DataType
.
U16_NHWC
)
\
.
dtype_format
(
DataType
.
U32_NHWC
,
DataType
.
U32_NHWC
)
\
.
dtype_format
(
DataType
.
U64_NHWC
,
DataType
.
U64_NHWC
)
\
.
get_op_info
()
@
op_info_register
(
depth_to_space_op_info
)
def
_depth_to_space_tbe
():
"""DepthToSpace TBE register"""
return
mindspore/ops/_op_impl/tbe/space_to_depth.py
0 → 100644
浏览文件 @
ba99cb7b
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
"""SpaceToDepth op"""
from
mindspore.ops.op_info_register
import
op_info_register
,
TBERegOp
,
DataType
space_to_depth_op_info
=
TBERegOp
(
"SpaceToDepth"
)
\
.
fusion_type
(
"OPAQUE"
)
\
.
async_flag
(
False
)
\
.
binfile_name
(
"space_to_depth.so"
)
\
.
compute_cost
(
10
)
\
.
kernel_name
(
"space_to_depth"
)
\
.
partial_flag
(
True
)
\
.
attr
(
"block_size"
,
"required"
,
"int"
,
"all"
)
\
.
attr
(
"data_format"
,
"optional"
,
"str"
,
"all"
)
\
.
input
(
0
,
"x"
,
False
,
"required"
,
"all"
)
\
.
output
(
0
,
"y"
,
False
,
"required"
,
"all"
)
\
.
dtype_format
(
DataType
.
F16_NHWC
,
DataType
.
F16_NHWC
)
\
.
dtype_format
(
DataType
.
F32_NHWC
,
DataType
.
F32_NHWC
)
\
.
dtype_format
(
DataType
.
I8_NHWC
,
DataType
.
I8_NHWC
)
\
.
dtype_format
(
DataType
.
I16_NHWC
,
DataType
.
I16_NHWC
)
\
.
dtype_format
(
DataType
.
I32_NHWC
,
DataType
.
I32_NHWC
)
\
.
dtype_format
(
DataType
.
I64_NHWC
,
DataType
.
I64_NHWC
)
\
.
dtype_format
(
DataType
.
U8_NHWC
,
DataType
.
U8_NHWC
)
\
.
dtype_format
(
DataType
.
U16_NHWC
,
DataType
.
U16_NHWC
)
\
.
dtype_format
(
DataType
.
U32_NHWC
,
DataType
.
U32_NHWC
)
\
.
dtype_format
(
DataType
.
U64_NHWC
,
DataType
.
U64_NHWC
)
\
.
get_op_info
()
@
op_info_register
(
space_to_depth_op_info
)
def
_space_to_depth_tbe
():
"""SpaceToDepth TBE register"""
return
mindspore/ops/operations/array_ops.py
浏览文件 @
ba99cb7b
...
...
@@ -2127,7 +2127,6 @@ class SpaceToDepth(PrimitiveWithInfer):
validator
.
check_value_type
(
'block_size'
,
block_size
,
[
int
],
self
.
name
)
validator
.
check
(
'block_size'
,
block_size
,
''
,
2
,
Rel
.
GE
)
self
.
block_size
=
block_size
self
.
add_prim_attr
(
"data_format"
,
"NCHW"
)
def
infer_shape
(
self
,
x_shape
):
validator
.
check
(
'x dimension'
,
len
(
x_shape
),
''
,
4
,
Rel
.
EQ
)
...
...
@@ -2185,7 +2184,6 @@ class DepthToSpace(PrimitiveWithInfer):
validator
.
check_value_type
(
'block_size'
,
block_size
,
[
int
],
self
.
name
)
validator
.
check
(
'block_size'
,
block_size
,
''
,
2
,
Rel
.
GE
,
self
.
name
)
self
.
block_size
=
block_size
self
.
add_prim_attr
(
"data_format"
,
"NCHW"
)
def
infer_shape
(
self
,
x_shape
):
validator
.
check
(
'x dimension'
,
len
(
x_shape
),
''
,
4
,
Rel
.
EQ
)
...
...
tests/ut/python/ops/test_array_ops.py
浏览文件 @
ba99cb7b
...
...
@@ -243,6 +243,25 @@ class UnpackNet(Cell):
def
construct
(
self
,
x
):
return
self
.
unpack
(
x
)
class
SpaceToDepthNet
(
Cell
):
def
__init__
(
self
):
super
(
SpaceToDepthNet
,
self
).
__init__
()
block_size
=
2
self
.
space_to_depth
=
P
.
SpaceToDepth
(
block_size
)
def
construct
(
self
,
x
):
return
self
.
space_to_depth
(
x
)
class
DepthToSpaceNet
(
Cell
):
def
__init__
(
self
):
super
(
DepthToSpaceNet
,
self
).
__init__
()
block_size
=
2
self
.
depth_to_space
=
P
.
DepthToSpace
(
block_size
)
def
construct
(
self
,
x
):
return
self
.
depth_to_space
(
x
)
test_case_array_ops
=
[
(
'CustNet1'
,
{
...
...
@@ -272,6 +291,12 @@ test_case_array_ops = [
(
'UnpackNet'
,
{
'block'
:
UnpackNet
(),
'desc_inputs'
:
[
Tensor
(
np
.
array
([[
1
,
2
],
[
3
,
4
]]).
astype
(
np
.
float16
))]}),
(
'SpaceToDepthNet'
,
{
'block'
:
SpaceToDepthNet
(),
'desc_inputs'
:
[
Tensor
(
np
.
random
.
rand
(
1
,
3
,
2
,
2
).
astype
(
np
.
float16
))]}),
(
'DepthToSpaceNet'
,
{
'block'
:
DepthToSpaceNet
(),
'desc_inputs'
:
[
Tensor
(
np
.
random
.
rand
(
1
,
12
,
1
,
1
).
astype
(
np
.
float16
))]}),
]
test_case_lists
=
[
test_case_array_ops
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录