Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
66e07efc
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看板
提交
66e07efc
编写于
6月 19, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
6月 19, 2020
浏览文件
操作
浏览文件
下载
差异文件
!2315 add Pack op for aicpu when axis=-1
Merge pull request !2315 from yanzhenxiang2020/add_pack_open
上级
002029ff
8621c032
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
222 addition
and
2 deletion
+222
-2
mindspore/ccsrc/kernel/aicpu/aicpu_kernel_metadata.cc
mindspore/ccsrc/kernel/aicpu/aicpu_kernel_metadata.cc
+2
-2
mindspore/ccsrc/kernel/aicpu/aicpu_util.h
mindspore/ccsrc/kernel/aicpu/aicpu_util.h
+1
-0
mindspore/ops/_op_impl/aicpu/__init__.py
mindspore/ops/_op_impl/aicpu/__init__.py
+1
-0
mindspore/ops/_op_impl/aicpu/pack.py
mindspore/ops/_op_impl/aicpu/pack.py
+41
-0
mindspore/ops/_op_impl/aicpu/topk.py
mindspore/ops/_op_impl/aicpu/topk.py
+1
-0
tests/st/ops/ascend/test_aicpu_ops/test_pack.py
tests/st/ops/ascend/test_aicpu_ops/test_pack.py
+176
-0
未找到文件。
mindspore/ccsrc/kernel/aicpu/aicpu_kernel_metadata.cc
浏览文件 @
66e07efc
...
...
@@ -38,10 +38,10 @@ void AicpuMetadataInfo(const CNodePtr &kernel_node, std::vector<std::shared_ptr<
return
;
}
// For compatibility with the current framework
if
(
op_name
==
kPrint
||
op_name
==
kGetNext
)
{
if
(
op_name
==
kPrint
||
op_name
==
kGetNext
||
op_name
==
kPack
)
{
std
::
vector
<
std
::
string
>
inputs_format
{};
std
::
vector
<
TypeId
>
inputs_type
{};
if
(
op_name
==
kPrint
)
{
if
(
op_name
==
kPrint
||
op_name
==
kPack
)
{
for
(
size_t
input_index
=
0
;
input_index
<
AnfAlgo
::
GetInputTensorNum
(
kernel_node
);
++
input_index
)
{
inputs_format
.
emplace_back
(
kOpFormat_DEFAULT
);
inputs_type
.
push_back
(
AnfAlgo
::
GetPrevNodeOutputInferDataType
(
kernel_node
,
input_index
));
...
...
mindspore/ccsrc/kernel/aicpu/aicpu_util.h
浏览文件 @
66e07efc
...
...
@@ -28,6 +28,7 @@ constexpr auto kInitDataSetQueue = "InitDataSetQueue";
constexpr
auto
kInitData
=
"InitData"
;
constexpr
auto
kGetNext
=
"GetNext"
;
constexpr
auto
kPrint
=
"Print"
;
constexpr
auto
kPack
=
"Pack"
;
constexpr
auto
kOutputTypes
=
"output_types"
;
constexpr
auto
kOutputShapes
=
"output_shapes"
;
constexpr
auto
kChannelName
=
"channel_name"
;
...
...
mindspore/ops/_op_impl/aicpu/__init__.py
浏览文件 @
66e07efc
...
...
@@ -24,3 +24,4 @@ from .flatten import _flatten_aicpu
from
.squeeze
import
_squeeze_aicpu
from
.expand_dims
import
_expand_dims_aicpu
from
.random_choice_with_mask
import
_random_choice_with_mask_aicpu
from
.pack
import
_pack_aicpu
mindspore/ops/_op_impl/aicpu/pack.py
0 → 100644
浏览文件 @
66e07efc
# 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.
# ============================================================================
"""Pack op"""
from
mindspore.ops.op_info_register
import
op_info_register
,
AiCPURegOp
,
DataType
pack_op_info
=
AiCPURegOp
(
"Pack"
)
\
.
fusion_type
(
"OPAQUE"
)
\
.
attr
(
"axis"
,
"int"
)
\
.
input
(
0
,
"x"
,
"dynamic"
)
\
.
output
(
0
,
"y"
,
"required"
)
\
.
dtype_format
(
DataType
.
I8_Default
,
DataType
.
I8_Default
)
\
.
dtype_format
(
DataType
.
I16_Default
,
DataType
.
I16_Default
)
\
.
dtype_format
(
DataType
.
I32_Default
,
DataType
.
I32_Default
)
\
.
dtype_format
(
DataType
.
I64_Default
,
DataType
.
I64_Default
)
\
.
dtype_format
(
DataType
.
U8_Default
,
DataType
.
U8_Default
)
\
.
dtype_format
(
DataType
.
U16_Default
,
DataType
.
U16_Default
)
\
.
dtype_format
(
DataType
.
U32_Default
,
DataType
.
U32_Default
)
\
.
dtype_format
(
DataType
.
U64_Default
,
DataType
.
U64_Default
)
\
.
dtype_format
(
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
.
dtype_format
(
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
.
dtype_format
(
DataType
.
F64_Default
,
DataType
.
F64_Default
)
\
.
dtype_format
(
DataType
.
BOOL_Default
,
DataType
.
BOOL_Default
)
\
.
get_op_info
()
@
op_info_register
(
pack_op_info
)
def
_pack_aicpu
():
"""Pack AiCPU register"""
return
mindspore/ops/_op_impl/aicpu/topk.py
浏览文件 @
66e07efc
...
...
@@ -24,6 +24,7 @@ top_k_op_info = AiCPURegOp("TopK") \
.
output
(
0
,
"values"
,
"required"
)
\
.
output
(
1
,
"indices"
,
"required"
)
\
.
dtype_format
(
DataType
.
F16_Default
,
DataType
.
I32_Default
,
DataType
.
F16_Default
,
DataType
.
I32_Default
)
\
.
dtype_format
(
DataType
.
F32_Default
,
DataType
.
I32_Default
,
DataType
.
F32_Default
,
DataType
.
I32_Default
)
\
.
dtype_format
(
DataType
.
I32_Default
,
DataType
.
I32_Default
,
DataType
.
I32_Default
,
DataType
.
I32_Default
)
\
.
get_op_info
()
...
...
tests/st/ops/ascend/test_aicpu_ops/test_pack.py
0 → 100644
浏览文件 @
66e07efc
# 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.
# ============================================================================
import
numpy
as
np
import
mindspore.context
as
context
import
mindspore.nn
as
nn
from
mindspore
import
Tensor
from
mindspore.ops
import
operations
as
P
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"Ascend"
)
class
Net
(
nn
.
Cell
):
def
__init__
(
self
,
x
,
axis
):
super
(
Net
,
self
).
__init__
()
self
.
pack
=
P
.
Pack
(
axis
)
self
.
x
=
x
def
construct
(
self
):
return
self
.
pack
(
self
.
x
)
def
test_net_bool
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
)
>
0
y
=
np
.
random
.
randn
(
3
,
5
,
4
)
>
0
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_int8
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int8
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int8
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_uint8
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint8
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint8
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_int16
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int16
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int16
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_uint16
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint16
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint16
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_int32
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int32
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int32
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_uint32
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint32
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint32
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_int64
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int64
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
int64
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_uint64
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint64
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
uint64
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_float16
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float16
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float16
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_float32
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float32
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float32
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
def
test_net_float64
():
x
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float64
)
y
=
np
.
random
.
randn
(
3
,
5
,
4
).
astype
(
np
.
float64
)
axis
=
-
1
net
=
Net
((
Tensor
(
x
),
Tensor
(
y
)),
axis
)
output
=
net
()
print
(
x
)
print
(
y
)
print
(
output
.
asnumpy
())
assert
np
.
array_equal
(
output
.
asnumpy
(),
np
.
stack
([
x
,
y
],
axis
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录