Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
06a6af76
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看板
提交
06a6af76
编写于
8月 17, 2020
作者:
W
wuxuejian
提交者:
jonyguo
9月 02, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update aicpu proto and update module: graphengine
Support Dynamic Shape Aicpu Run Package
上级
9833a00e
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
259 addition
and
62 deletion
+259
-62
graphengine
graphengine
+1
-1
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc
...ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc
+112
-2
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.cc
...e/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.cc
+22
-5
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.h
...re/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.h
+2
-0
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_util.h
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_util.h
+30
-1
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/attr.proto
...pore/ccsrc/backend/kernel_compiler/aicpu/proto/attr.proto
+1
-1
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/node_def.proto
.../ccsrc/backend/kernel_compiler/aicpu/proto/node_def.proto
+7
-0
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/tensor.proto
...re/ccsrc/backend/kernel_compiler/aicpu/proto/tensor.proto
+4
-1
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/tensor_shape.proto
...rc/backend/kernel_compiler/aicpu/proto/tensor_shape.proto
+1
-1
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/types.proto
...ore/ccsrc/backend/kernel_compiler/aicpu/proto/types.proto
+25
-12
mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc
mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc
+13
-0
mindspore/ccsrc/backend/session/anf_runtime_algorithm.h
mindspore/ccsrc/backend/session/anf_runtime_algorithm.h
+1
-0
mindspore/ccsrc/utils/utils.h
mindspore/ccsrc/utils/utils.h
+1
-0
mindspore/ops/_op_impl/aicpu/__init__.py
mindspore/ops/_op_impl/aicpu/__init__.py
+1
-0
mindspore/ops/_op_impl/aicpu/unique.py
mindspore/ops/_op_impl/aicpu/unique.py
+31
-0
mindspore/ops/operations/__init__.py
mindspore/ops/operations/__init__.py
+1
-0
mindspore/ops/operations/array_ops.py
mindspore/ops/operations/array_ops.py
+2
-2
tests/st/networks/models/resnet50/test_resnet50_imagenet.py
tests/st/networks/models/resnet50/test_resnet50_imagenet.py
+4
-2
tests/ut/cpp/stub/tdt/tdt_mock.cc
tests/ut/cpp/stub/tdt/tdt_mock.cc
+0
-34
未找到文件。
graphengine
@
cb39cb2b
Subproject commit
622af6c1c50034bea5a08bd409c5a410782bfe53
Subproject commit
cb39cb2ba7c9afb27373ad9e81f563ff9ddb9fcc
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_build.cc
浏览文件 @
06a6af76
...
...
@@ -20,6 +20,8 @@
#include <vector>
#include <memory>
#include <algorithm>
#include <map>
#include <climits>
#include "runtime/device/kernel_runtime.h"
#include "backend/kernel_compiler/aicpu/aicpu_kernel_mod.h"
#include "backend/kernel_compiler/akg/akg_kernel_build.h"
...
...
@@ -218,7 +220,7 @@ void SetNodeInputs(const std::shared_ptr<AnfNode> &anf_node, mindspore::NodeDef
mindspore
::
TensorShape_Dim
*
dim
=
tensorShape
->
add_dim
();
dim
->
set_size
((
::
google
::
protobuf
::
int64
)
item
);
}
node_inputs
->
set_tensor_type
(
(
mindspore
::
DataType
)
input_data_type
);
node_inputs
->
set_tensor_type
(
input_data_type
);
node_inputs
->
set_mem_device
(
"HBM"
);
}
}
...
...
@@ -245,7 +247,7 @@ void SetNodeOutputs(const std::shared_ptr<AnfNode> &anf_node, mindspore::NodeDef
}
TypeId
output_type
=
AnfAlgo
::
GetOutputDeviceDataType
(
anf_node
,
output_index
);
int32_t
output_data_type
=
AicpuOpUtil
::
MsTypeToProtoType
(
output_type
);
node_outputs
->
set_tensor_type
(
(
mindspore
::
DataType
)
output_data_type
);
node_outputs
->
set_tensor_type
(
output_data_type
);
node_outputs
->
set_mem_device
(
"HBM"
);
}
}
...
...
@@ -287,6 +289,109 @@ bool CreateNodeDefBytes(const std::shared_ptr<AnfNode> &anf_node,
return
true
;
}
bool
CreateExtInfo
(
const
std
::
shared_ptr
<
AnfNode
>
&
anf_node
,
const
std
::
shared_ptr
<
AicpuOpKernelMod
>
&
kernel_mod_ptr
)
{
if
(
!
anf_node
->
isa
<
CNode
>
())
{
return
true
;
}
if
(
!
AnfAlgo
::
IsDynamicShape
(
anf_node
))
{
return
true
;
}
MS_LOG
(
INFO
)
<<
"CreateExtInfo start, "
<<
anf_node
->
fullname_with_scope
();
int32_t
unknown_shape_type
=
UnknowShapeOpType
::
DEPEND_COMPUTE
;
uint64_t
ext_info_head_len
=
kExtInfoHeadSize
;
std
::
string
ext_info
;
size_t
input_num
=
AnfAlgo
::
GetInputTensorNum
(
anf_node
);
size_t
output_num
=
AnfAlgo
::
GetOutputTensorNum
(
anf_node
);
// 1.addr:unknown shape type
uint64_t
ext_info_len
=
ext_info
.
size
();
ext_info_len
+=
ext_info_head_len
+
sizeof
(
int32_t
);
// 2.addr:input ShapeAndType
ext_info_len
+=
ext_info_head_len
+
input_num
*
sizeof
(
ShapeAndType
);
// 3.addr:output ShapeAndType
ext_info_len
+=
ext_info_head_len
+
output_num
*
sizeof
(
ShapeAndType
);
uint64_t
ext_info_offset
=
ext_info
.
size
();
ext_info
.
resize
(
ext_info_len
,
0
);
char
*
ext_info_buf
=
ext_info
.
data
();
// deal1: unknown shape type
ExtInfo
*
info
=
reinterpret_cast
<
ExtInfo
*>
(
ext_info_buf
+
ext_info_offset
);
info
->
infoType
=
FWK_ADPT_EXT_SHAPE_TYPE
;
info
->
infoLen
=
sizeof
(
int32_t
);
ext_info_offset
+=
ext_info_head_len
;
int32_t
*
shape_type
=
reinterpret_cast
<
int32_t
*>
(
ext_info_buf
+
ext_info_offset
);
*
shape_type
=
unknown_shape_type
;
ext_info_offset
+=
info
->
infoLen
;
// deal2:input ShapeAndType
info
=
reinterpret_cast
<
ExtInfo
*>
(
ext_info_buf
+
ext_info_offset
);
info
->
infoType
=
FWK_ADPT_EXT_INPUT_SHAPE
;
info
->
infoLen
=
input_num
*
sizeof
(
ShapeAndType
);
ext_info_offset
+=
ext_info_head_len
;
ShapeAndType
*
inputs
=
reinterpret_cast
<
ShapeAndType
*>
(
ext_info_buf
+
ext_info_offset
);
for
(
size_t
input_index
=
0
;
input_index
<
input_num
;
input_index
++
)
{
TypeId
input_type
=
AnfAlgo
::
GetInputDeviceDataType
(
anf_node
,
input_index
);
std
::
vector
<
size_t
>
input_shape
;
int32_t
input_data_type
;
if
(
input_type
==
kObjectTypeString
)
{
auto
cnode
=
anf_node
->
cast
<
CNodePtr
>
();
MS_EXCEPTION_IF_NULL
(
cnode
);
auto
input_node
=
cnode
->
inputs
()[
input_index
+
1
];
auto
value_ptr
=
GetValueNode
(
input_node
);
auto
value
=
GetValue
<
std
::
string
>
(
value_ptr
);
input_shape
.
push_back
(
1
);
input_shape
.
push_back
(
value
.
size
());
input_data_type
=
AicpuOpUtil
::
MsTypeToProtoType
(
kTypeUnknown
);
}
else
{
input_shape
=
AnfAlgo
::
GetInputDeviceShape
(
anf_node
,
input_index
);
input_data_type
=
AicpuOpUtil
::
MsTypeToProtoType
(
input_type
);
}
inputs
[
input_index
].
type
=
input_data_type
;
size_t
input_shape_index
=
0
;
for
(;
input_shape_index
<
input_shape
.
size
();
input_shape_index
++
)
{
inputs
[
input_index
].
dims
[
input_shape_index
]
=
SizeToLong
(
input_shape
[
input_shape_index
]);
}
if
(
input_shape
.
size
()
<
kMaxShapeDims
)
{
inputs
[
input_index
].
dims
[
input_shape_index
]
=
LLONG_MIN
;
}
}
ext_info_offset
+=
info
->
infoLen
;
// deal3:output ShapeAndType
info
=
reinterpret_cast
<
ExtInfo
*>
(
ext_info_buf
+
ext_info_offset
);
info
->
infoType
=
FWK_ADPT_EXT_OUTPUT_SHAPE
;
info
->
infoLen
=
output_num
*
sizeof
(
ShapeAndType
);
ext_info_offset
+=
ext_info_head_len
;
ShapeAndType
*
outputs
=
reinterpret_cast
<
ShapeAndType
*>
(
ext_info_buf
+
ext_info_offset
);
for
(
size_t
output_index
=
0
;
output_index
<
output_num
;
output_index
++
)
{
std
::
vector
<
size_t
>
output_shape
=
AnfAlgo
::
GetOutputDeviceShape
(
anf_node
,
output_index
);
TypeId
output_type
=
AnfAlgo
::
GetOutputDeviceDataType
(
anf_node
,
output_index
);
int32_t
output_data_type
=
AicpuOpUtil
::
MsTypeToProtoType
(
output_type
);
outputs
[
output_index
].
type
=
output_data_type
;
size_t
output_shape_index
=
0
;
for
(;
output_shape_index
<
output_shape
.
size
();
output_shape_index
++
)
{
outputs
[
output_index
].
dims
[
output_shape_index
]
=
SizeToLong
(
output_shape
[
output_shape_index
]);
}
if
(
output_shape_index
<
kMaxShapeDims
)
{
outputs
[
output_index
].
dims
[
output_shape_index
]
=
LLONG_MIN
;
}
}
// set ext info
kernel_mod_ptr
->
SetExtInfo
(
ext_info
);
return
true
;
}
KernelModPtr
AicpuOpBuild
(
const
std
::
shared_ptr
<
AnfNode
>
&
anf_node
)
{
MS_EXCEPTION_IF_NULL
(
anf_node
);
std
::
string
op_name
=
AnfAlgo
::
GetCNodeName
(
anf_node
);
...
...
@@ -300,6 +405,11 @@ KernelModPtr AicpuOpBuild(const std::shared_ptr<AnfNode> &anf_node) {
if
(
!
CreateNodeDefBytes
(
anf_node
,
kernel_mod_ptr
))
{
MS_LOG
(
EXCEPTION
)
<<
"Create nodeDefBytes faild!"
;
}
if
(
!
CreateExtInfo
(
anf_node
,
kernel_mod_ptr
))
{
MS_LOG
(
EXCEPTION
)
<<
"Create nodeDefBytes faild!"
;
}
if
(
!
SetIOSize
(
anf_node
,
kernel_mod_ptr
))
{
MS_LOG
(
EXCEPTION
)
<<
"Set input output size list failed."
;
}
...
...
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.cc
浏览文件 @
06a6af76
...
...
@@ -43,6 +43,7 @@ AicpuOpKernelMod::~AicpuOpKernelMod() {
input_size_list_
.
clear
();
output_size_list_
.
clear
();
workspace_size_list_
.
clear
();
ext_info_
.
clear
();
}
void
AicpuOpKernelMod
::
SetInputSizeList
(
const
std
::
vector
<
size_t
>
&
size_list
)
{
input_size_list_
=
size_list
;
}
...
...
@@ -54,6 +55,7 @@ const std::vector<size_t> &AicpuOpKernelMod::GetWorkspaceSizeList() const { retu
void
AicpuOpKernelMod
::
SetInputList
(
const
std
::
vector
<
int64_t
>
&
inputList
)
{
inputList_
=
inputList
;
}
void
AicpuOpKernelMod
::
SetOutputList
(
const
std
::
vector
<
int64_t
>
&
outputList
)
{
outputList_
=
outputList
;
}
void
AicpuOpKernelMod
::
SetNodeDef
(
const
std
::
string
&
nodeDef
)
{
(
void
)
node_def_str_
.
assign
(
nodeDef
);
}
void
AicpuOpKernelMod
::
SetExtInfo
(
const
std
::
string
&
ext_info
)
{
ext_info_
=
ext_info
;
}
void
AicpuOpKernelMod
::
SetNodeName
(
const
std
::
string
&
node_name
)
{
node_name_
=
node_name
;
}
void
AicpuOpKernelMod
::
SetAnfNode
(
const
mindspore
::
AnfNodePtr
&
anf_node
)
{
MS_EXCEPTION_IF_NULL
(
anf_node
);
...
...
@@ -84,16 +86,30 @@ void AicpuOpKernelMod::CreateCpuKernelInfo(const std::vector<AddressPtr> &inputs
auto
node_def_len
=
node_def_str_
.
length
();
param_len
+=
node_def_len
;
param_len
+=
sizeof
(
uint32_t
);
AicpuParamHead
aicpu_param_head
;
aicpu_param_head
.
length
=
param_len
;
aicpu_param_head
.
ioAddrNum
=
io_addrs_num
;
if
(
ext_info_
.
empty
())
{
MS_LOG
(
INFO
)
<<
"Static Shape Kernel"
;
aicpu_param_head
.
extInfoLength
=
0
;
aicpu_param_head
.
extInfoAddr
=
0
;
}
else
{
MS_LOG
(
INFO
)
<<
"Dynamic Kernel Ext Info size:"
<<
ext_info_
.
size
();
}
// Create taskArgs: AicpuParamHead + ioAddrs + notifyId + customizedAttr
AicpuParamHead
paramHead
=
{
static_cast
<
uint32_t
>
(
param_len
),
static_cast
<
uint32_t
>
(
io_addrs_num
)};
args_
.
clear
();
(
void
)
args_
.
append
(
reinterpret_cast
<
const
char
*>
(
&
paramH
ead
),
sizeof
(
AicpuParamHead
));
(
void
)
args_
.
append
(
reinterpret_cast
<
const
char
*>
(
&
aicpu_param_h
ead
),
sizeof
(
AicpuParamHead
));
// TaskArgs append ioAddrs
if
(
io_addrs_size
!=
0
)
{
(
void
)
args_
.
append
(
reinterpret_cast
<
const
char
*>
(
io_addrs
.
data
()),
io_addrs_size
);
}
// size for node_def
args_
.
append
(
reinterpret_cast
<
const
char
*>
(
&
node_def_len
),
sizeof
(
uint32_t
));
// When it's aicpu customized ops, taskArgs should append customized attr
if
(
node_def_len
!=
0
)
{
(
void
)
args_
.
append
(
reinterpret_cast
<
const
char
*>
(
node_def_str_
.
data
()),
node_def_len
);
...
...
@@ -145,8 +161,9 @@ std::vector<TaskInfoPtr> AicpuOpKernelMod::GenTask(const std::vector<AddressPtr>
node_name_
=
kTopKV2
;
}
AicpuTaskInfoPtr
task_info_ptr
=
make_shared
<
ge
::
model_runner
::
AicpuTaskInfo
>
(
kernel_name_
,
stream_id
,
node_so_
,
node_name_
,
node_def_str_
,
input_data_addrs
,
output_data_addrs
,
NeedDump
());
AicpuTaskInfoPtr
task_info_ptr
=
make_shared
<
ge
::
model_runner
::
AicpuTaskInfo
>
(
kernel_name_
,
stream_id
,
node_so_
,
node_name_
,
node_def_str_
,
ext_info_
,
input_data_addrs
,
output_data_addrs
,
NeedDump
());
MS_LOG
(
INFO
)
<<
"AicpuOpKernelMod GenTask end"
;
return
{
task_info_ptr
};
...
...
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_kernel_mod.h
浏览文件 @
06a6af76
...
...
@@ -36,6 +36,7 @@ class AicpuOpKernelMod : public AscendKernelMod {
void
SetOutputList
(
const
std
::
vector
<
int64_t
>
&
outputList
);
void
SetAnfNode
(
const
AnfNodePtr
&
anf_node
);
void
SetNodeDef
(
const
std
::
string
&
nodeDef
);
void
SetExtInfo
(
const
std
::
string
&
ext_info
);
void
SetNodeName
(
const
std
::
string
&
node_name
);
/**
...
...
@@ -58,6 +59,7 @@ class AicpuOpKernelMod : public AscendKernelMod {
std
::
string
node_def_str_
;
std
::
string
node_name_
;
std
::
string
node_so_
;
std
::
string
ext_info_
;
std
::
vector
<
int64_t
>
inputList_
;
std
::
vector
<
int64_t
>
outputList_
;
AnfNodePtr
anf_node_
;
...
...
mindspore/ccsrc/backend/kernel_compiler/aicpu/aicpu_util.h
浏览文件 @
06a6af76
...
...
@@ -21,7 +21,6 @@
#include <map>
#include <string>
#include "backend/kernel_compiler/kernel.h"
namespace
mindspore
{
namespace
kernel
{
constexpr
auto
kInitDataSetQueue
=
"InitDataSetQueue"
;
...
...
@@ -50,6 +49,36 @@ struct AicpuParamHead {
uint64_t
extInfoAddr
;
// extInfo address
}
__attribute__
((
packed
));
const
uint32_t
kExtInfoHeadSize
=
8
;
struct
ExtInfo
{
int32_t
infoType
;
// extend type
uint32_t
infoLen
;
// length for infoMsg
char
infoMsg
[
0
];
// extend value
}
__attribute__
((
packed
));
// Extent info ShapeAndType
const
uint32_t
kMaxShapeDims
=
8
;
struct
ShapeAndType
{
int32_t
type
;
int64_t
dims
[
kMaxShapeDims
];
}
__attribute__
((
packed
));
// Extend Info type for task
enum
FWKTaskExtInfoType
{
FWK_ADPT_EXT_SHAPE_TYPE
=
0
,
FWK_ADPT_EXT_INPUT_SHAPE
,
FWK_ADPT_EXT_OUTPUT_SHAPE
,
FWK_ADPT_EXT_INVALID
};
// for unknown shape op type
enum
UnknowShapeOpType
{
DEPEND_IN_SHAPE
=
1
,
// op out shape get by input shape
DEPEND_CONST_VALUE
=
2
,
// op out shape get by const op value
DEPEND_SHAPE_RANGE
=
3
,
// op out shape get by range
DEPEND_COMPUTE
=
4
// op out shape get by totally computing
};
class
AicpuOpUtil
{
public:
static
int
MsTypeToProtoType
(
TypeId
ms_type
);
...
...
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/attr.proto
浏览文件 @
06a6af76
...
...
@@ -26,7 +26,7 @@ message AttrValue {
repeated
int64
i
=
3
[
packed
=
true
];
//"array(int)"
repeated
float
f
=
4
[
packed
=
true
];
//"array(float)"
repeated
bool
b
=
5
[
packed
=
true
];
//"array(bool)"
repeated
DataType
type
=
6
[
packed
=
true
];
//"array(type)"
repeated
int32
type
=
6
[
packed
=
true
];
//"array(type)"
repeated
TensorShape
shape
=
7
;
//"array(shape)"
repeated
Tensor
tensor
=
8
;
//"array(tensor)"
}
...
...
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/node_def.proto
浏览文件 @
06a6af76
...
...
@@ -18,9 +18,16 @@ package mindspore;
import
"attr.proto"
;
import
"tensor.proto"
;
message
DynamicIdx
{
int32
idx
=
1
;
int32
num
=
2
;
}
message
NodeDef
{
string
op
=
2
;
map
<
string
,
AttrValue
>
attrs
=
3
;
repeated
Tensor
inputs
=
4
;
repeated
Tensor
outputs
=
5
;
map
<
string
,
DynamicIdx
>
dym_inputs
=
6
;
map
<
string
,
DynamicIdx
>
dym_outputs
=
7
;
}
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/tensor.proto
浏览文件 @
06a6af76
...
...
@@ -26,9 +26,12 @@ message Tensor {
TensorShape
tensor_shape
=
1
;
// tensor content data type
DataType
tensor_type
=
2
;
int32
tensor_type
=
2
;
// tensor memory device
// data located memory device , "DDR" "HBM" OR "NONE"
string
mem_device
=
3
;
string
name
=
4
;
uint64
data_ptr
=
5
;
uint64
data_size
=
6
;
}
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/tensor_shape.proto
浏览文件 @
06a6af76
...
...
@@ -31,5 +31,5 @@ message TensorShape {
bool
unknown_rank
=
3
;
// data format "NHWC" "NCHW" "NC1HWC0" OR "NONE"
string
data_format
=
4
;
int32
data_format
=
4
;
};
mindspore/ccsrc/backend/kernel_compiler/aicpu/proto/types.proto
浏览文件 @
06a6af76
...
...
@@ -19,17 +19,30 @@ option cc_enable_arenas = true;
package
mindspore
;
enum
DataType
{
MS_
UNKNOWN
=
0
;
MS_
BOOL
=
1
;
MS_
FLOAT32
=
0
;
MS_
FLOAT16
=
1
;
MS_INT8
=
2
;
MS_UINT8
=
3
;
MS_INT16
=
4
;
MS_UINT16
=
5
;
MS_INT32
=
6
;
MS_UINT32
=
7
;
MS_INT64
=
8
;
MS_UINT64
=
9
;
MS_FLOAT16
=
10
;
MS_FLOAT32
=
11
;
MS_FLOAT64
=
12
;
MS_INT32
=
3
;
MS_UINT8
=
4
;
MS_INT16
=
6
;
MS_UINT16
=
7
;
MS_UINT32
=
8
;
MS_INT64
=
9
;
MS_UINT64
=
10
;
MS_FLOAT64
=
11
;
MS_BOOL
=
12
;
MS_STRING
=
13
;
MS_DUAL_SUB_INT8
=
14
;
MS_DUAL_SUB_UINT8
=
15
;
MS_COMPLEX64
=
16
;
MS_COMPLEX128
=
17
;
MS_QINT8
=
18
;
MS_QINT16
=
19
;
MS_QINT32
=
20
;
MS_QUINT8
=
21
;
MS_QUINT16
=
22
;
MS_RESOURCE
=
23
;
MS_STRING_REF
=
24
;
MS_DUAL
=
25
;
MS_UNKNOWN
=
26
;
}
mindspore/ccsrc/backend/session/anf_runtime_algorithm.cc
浏览文件 @
06a6af76
...
...
@@ -1197,6 +1197,19 @@ TypeId AnfRuntimeAlgorithm::GetPrevNodeOutputPrecision(const AnfNodePtr &node, s
return
GetCNodeOutputPrecision
(
kernel_with_index
.
first
);
}
bool
AnfRuntimeAlgorithm
::
IsDynamicShape
(
const
AnfNodePtr
&
node
)
{
if
(
!
node
->
isa
<
CNode
>
())
{
return
false
;
}
auto
cnode
=
node
->
cast
<
CNodePtr
>
();
MS_EXCEPTION_IF_NULL
(
cnode
);
auto
has_attr
=
AnfAlgo
::
HasNodeAttr
(
kAttrIsDynamicShape
,
cnode
);
if
(
!
has_attr
)
{
return
false
;
}
return
AnfAlgo
::
GetNodeAttr
<
bool
>
(
node
,
kAttrIsDynamicShape
);
}
bool
AnfRuntimeAlgorithm
::
IsCondControlKernel
(
const
CNodePtr
&
node
)
{
MS_EXCEPTION_IF_NULL
(
node
);
if
(
node
->
inputs
().
empty
())
{
...
...
mindspore/ccsrc/backend/session/anf_runtime_algorithm.h
浏览文件 @
06a6af76
...
...
@@ -217,6 +217,7 @@ class AnfRuntimeAlgorithm {
static
TypeId
GetCNodeOutputPrecision
(
const
AnfNodePtr
&
node
);
// get fix output precision from prev node, input_idx is the input index of current node related to prev node.
static
TypeId
GetPrevNodeOutputPrecision
(
const
AnfNodePtr
&
node
,
size_t
input_idx
);
static
bool
IsDynamicShape
(
const
AnfNodePtr
&
node
);
static
bool
IsCondControlKernel
(
const
CNodePtr
&
node
);
static
bool
IsIndependentNode
(
const
CNodePtr
&
node
);
};
...
...
mindspore/ccsrc/utils/utils.h
浏览文件 @
06a6af76
...
...
@@ -269,6 +269,7 @@ constexpr auto kAttrPadDimSize = "pad_dim_size";
constexpr
auto
kAttrNumSegments
=
"num_segments"
;
constexpr
auto
kAttrBegin
=
"begin"
;
constexpr
auto
kAttrSize
=
"size"
;
constexpr
auto
kAttrIsDynamicShape
=
"is_dynamic_shape"
;
// attr value
constexpr
auto
kValueTargetSwitch
=
"target_switch"
;
...
...
mindspore/ops/_op_impl/aicpu/__init__.py
浏览文件 @
06a6af76
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
"""aicpu ops"""
from
.unique
import
_unique_aicpu
from
.init_data_set_queue
import
_init_data_set_queue_aicpu
from
.embedding_lookup
import
_embedding_lookup_aicpu
from
.padding
import
_padding_aicpu
...
...
mindspore/ops/_op_impl/aicpu/unique.py
0 → 100644
浏览文件 @
06a6af76
# 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.
# ============================================================================
"""Unique op"""
from
mindspore.ops.op_info_register
import
op_info_register
,
AiCPURegOp
,
DataType
unique_op_info
=
AiCPURegOp
(
"Unique"
)
\
.
fusion_type
(
"OPAQUE"
)
\
.
input
(
0
,
"x"
,
"required"
)
\
.
output
(
0
,
"y"
,
"required"
)
\
.
output
(
1
,
"idx"
,
"required"
)
\
.
dtype_format
(
DataType
.
I32_Default
,
DataType
.
I32_Default
,
DataType
.
I32_Default
)
\
.
dtype_format
(
DataType
.
I64_Default
,
DataType
.
I64_Default
,
DataType
.
I64_Default
)
\
.
get_op_info
()
@
op_info_register
(
unique_op_info
)
def
_unique_aicpu
():
"""Unique AiCPU register"""
return
mindspore/ops/operations/__init__.py
浏览文件 @
06a6af76
...
...
@@ -91,6 +91,7 @@ from ._thor_ops import (CusBatchMatMul, CusCholeskyTrsm, CusFusedAbsMax1, CusImg
from
.sparse_ops
import
SparseToDense
__all__
=
[
'Unique'
,
'ReverseSequence'
,
'EditDistance'
,
'CropAndResize'
,
...
...
mindspore/ops/operations/array_ops.py
浏览文件 @
06a6af76
...
...
@@ -569,9 +569,9 @@ class Unique(Primitive):
containing indices of elements in the input coressponding to the output tensor.
Examples:
>>> x = Tensor(np.array([1, 2, 5, 2]), mindspore.
floa
t32)
>>> x = Tensor(np.array([1, 2, 5, 2]), mindspore.
in
t32)
>>> out = P.Unique()(x)
(Tensor([1, 2, 5], mindspore.int32), Tensor([0, 1, 2, 1], mindspore.
floa
t32))
(Tensor([1, 2, 5], mindspore.int32), Tensor([0, 1, 2, 1], mindspore.
in
t32))
"""
@
prim_attr_register
def
__init__
(
self
):
...
...
tests/st/networks/models/resnet50/test_resnet50_imagenet.py
浏览文件 @
06a6af76
...
...
@@ -367,7 +367,8 @@ def test_resnet_and_resnet_thor_imagenet_4p():
os
.
system
(
"rm -rf "
+
str
(
i
))
print
(
"End training..."
)
assert
acc
>
0.15
assert
cost
<
20
# the original perf is: 20 in C75B100
assert
cost
<
22
# THOR
thor_acc
=
0.0
...
...
@@ -383,4 +384,5 @@ def test_resnet_and_resnet_thor_imagenet_4p():
os
.
system
(
"rm -rf "
+
str
(
i
))
print
(
"End training..."
)
assert
thor_acc
>
0.22
assert
thor_cost
<
21
# the original perf is: 21 in C75B100
assert
thor_cost
<
23
tests/ut/cpp/stub/tdt/tdt_mock.cc
浏览文件 @
06a6af76
...
...
@@ -35,39 +35,5 @@ StatusFactory::StatusFactory() {}
std
::
mutex
&
StatusFactory
::
GetMutex
()
{
return
GetInstance
()
->
rwMutex_
;
}
TsdClient
*
TsdClient
::
GetInstance
()
{
static
TsdClient
instance
;
return
&
instance
;
}
/**
* @ingroup TsdClient
* @brief 构造函数
*/
TsdClient
::
TsdClient
()
{
rankSize_
=
1
;
}
/**
* @ingroup TsdClient
* @brief 析构函数
*/
TsdClient
::~
TsdClient
()
=
default
;
/**
* @ingroup TsdClient
* @brief framework发送拉起hccp和computer process的命令
* @param [in] phyDeviceId : FMK传入物理ID
* @param [in] phyDeviceId : FMK传入rankSize
* @return TDT_OK:成功 或者其他错误码
*/
TDT_StatusT
TsdClient
::
Open
(
const
uint32_t
deviceId
,
const
uint32_t
rankSize
)
{
return
TDT_OK
;
}
/**
* @ingroup TsdClient
* @brief 通知TsdClient关闭相关资源
* @param 无
* @return TDT_OK:成功 或者其他错误码
*/
TDT_StatusT
TsdClient
::
Close
()
{
return
TDT_OK
;
}
}
// namespace tdt
#endif // TDT_MOCK_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录