Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
fe8f47dc
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看板
提交
fe8f47dc
编写于
6月 28, 2020
作者:
B
buxue
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add typeid to type conversion scene
上级
16a75779
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
61 addition
and
29 deletion
+61
-29
mindspore/ccsrc/debug/anf_ir_utils.cc
mindspore/ccsrc/debug/anf_ir_utils.cc
+1
-1
mindspore/ccsrc/ir/dtype.h
mindspore/ccsrc/ir/dtype.h
+5
-0
mindspore/ccsrc/ir/dtype/empty.cc
mindspore/ccsrc/ir/dtype/empty.cc
+2
-0
mindspore/ccsrc/ir/dtype/empty.h
mindspore/ccsrc/ir/dtype/empty.h
+8
-6
mindspore/ccsrc/ir/dtype_extends.cc
mindspore/ccsrc/ir/dtype_extends.cc
+25
-2
mindspore/ccsrc/ir/func_graph.cc
mindspore/ccsrc/ir/func_graph.cc
+4
-4
mindspore/ccsrc/ir/named.cc
mindspore/ccsrc/ir/named.cc
+4
-4
mindspore/ccsrc/ir/named.h
mindspore/ccsrc/ir/named.h
+8
-8
mindspore/ccsrc/pipeline/static_analysis/abstract_value.h
mindspore/ccsrc/pipeline/static_analysis/abstract_value.h
+2
-2
mindspore/ccsrc/utils/convert_utils.cc
mindspore/ccsrc/utils/convert_utils.cc
+1
-1
mindspore/common/dtype.py
mindspore/common/dtype.py
+1
-1
未找到文件。
mindspore/ccsrc/debug/anf_ir_utils.cc
浏览文件 @
fe8f47dc
...
...
@@ -400,7 +400,7 @@ std::string AnfExporter::GetValueText(const FuncGraphPtr &func_graph, const Valu
}
else
if
(
value
->
isa
<
tensor
::
Tensor
>
())
{
auto
tensor_ptr
=
dyn_cast
<
tensor
::
Tensor
>
(
value
);
oss
<<
value
->
DumpText
()
<<
"@"
<<
DumpObject
(
tensor_ptr
->
data
(),
"T"
);
}
else
if
(
value
->
isa
<
parse
::
Symbol
>
()
||
value
->
isa
<
None
>
()
||
value
->
isa
<
Null
Obj
>
())
{
}
else
if
(
value
->
isa
<
parse
::
Symbol
>
()
||
value
->
isa
<
None
>
()
||
value
->
isa
<
Null
>
())
{
oss
<<
value
->
DumpText
();
}
else
if
(
value
->
isa
<
ValueSequeue
>
())
{
oss
<<
GetSequenceText
(
func_graph
,
value
);
...
...
mindspore/ccsrc/ir/dtype.h
浏览文件 @
fe8f47dc
...
...
@@ -275,6 +275,11 @@ extern const TypePtr kTypeExternal;
extern
const
TypePtr
kTypeEnv
;
extern
const
TypePtr
kTypeType
;
extern
const
TypePtr
kString
;
extern
const
TypePtr
kList
;
extern
const
TypePtr
kTuple
;
extern
const
TypePtr
kDict
;
extern
const
TypePtr
kSlice
;
extern
const
TypePtr
kKeyword
;
extern
const
TypePtr
kTensorType
;
}
// namespace mindspore
...
...
mindspore/ccsrc/ir/dtype/empty.cc
浏览文件 @
fe8f47dc
...
...
@@ -18,5 +18,7 @@
namespace
mindspore
{
const
TypePtr
kTypeNone
=
std
::
make_shared
<
TypeNone
>
();
const
TypePtr
kTypeNull
=
std
::
make_shared
<
TypeNull
>
();
const
TypePtr
kTypeEllipsis
=
std
::
make_shared
<
TypeEllipsis
>
();
const
TypePtr
kAnyType
=
std
::
make_shared
<
TypeAnything
>
();
}
// namespace mindspore
mindspore/ccsrc/ir/dtype/empty.h
浏览文件 @
fe8f47dc
...
...
@@ -71,20 +71,22 @@ class TypeNull : public Type {
};
using
TypeNullPtr
=
std
::
shared_ptr
<
TypeNull
>
;
class
Ellipsis
:
public
Type
{
class
Type
Ellipsis
:
public
Type
{
public:
Ellipsis
()
:
Type
(
kMetaTypeEllipsis
)
{}
~
Ellipsis
()
override
{}
MS_DECLARE_PARENT
(
Ellipsis
,
Type
)
Type
Ellipsis
()
:
Type
(
kMetaTypeEllipsis
)
{}
~
Type
Ellipsis
()
override
{}
MS_DECLARE_PARENT
(
Type
Ellipsis
,
Type
)
TypeId
generic_type_id
()
const
override
{
return
kMetaTypeEllipsis
;
}
TypePtr
DeepCopy
()
const
override
{
return
std
::
make_shared
<
Ellipsis
>
();
}
TypePtr
DeepCopy
()
const
override
{
return
std
::
make_shared
<
Type
Ellipsis
>
();
}
std
::
string
ToReprString
()
const
override
{
return
"Ellipsis"
;
}
std
::
string
DumpText
()
const
override
{
return
"Ellipsis"
;
}
};
using
EllipsisPtr
=
std
::
shared_ptr
<
Ellipsis
>
;
using
TypeEllipsisPtr
=
std
::
shared_ptr
<
Type
Ellipsis
>
;
extern
const
TypePtr
kTypeNone
;
extern
const
TypePtr
kTypeNull
;
extern
const
TypePtr
kTypeEllipsis
;
extern
const
TypePtr
kAnyType
;
}
// namespace mindspore
...
...
mindspore/ccsrc/ir/dtype_extends.cc
浏览文件 @
fe8f47dc
...
...
@@ -95,12 +95,30 @@ TypePtr TypeIdToType(TypeId id) {
return
kAnyType
;
case
kMetaTypeNone
:
return
kTypeNone
;
case
kMetaTypeNull
:
return
kTypeNull
;
case
kMetaTypeEllipsis
:
return
kTypeEllipsis
;
case
kObjectTypeEnvType
:
return
kTypeEnv
;
case
kObjectTypeRefKey
:
return
kRefKeyType
;
case
kObjectTypeRef
:
return
kRefType
;
case
kMetaTypeTypeType
:
return
kTypeType
;
case
kObjectTypeString
:
return
kString
;
case
kObjectTypeList
:
return
kList
;
case
kObjectTypeTuple
:
return
kTuple
;
case
kObjectTypeDictionary
:
return
kDict
;
case
kObjectTypeSlice
:
return
kSlice
;
case
kObjectTypeKeyword
:
return
kKeyword
;
case
kTypeUnknown
:
return
kTypeNone
;
default:
...
...
@@ -274,7 +292,7 @@ TypePtr StringToType(const std::string &type_name) {
if
(
type_name
.
compare
(
"None"
)
==
0
)
{
type
=
std
::
make_shared
<
TypeNone
>
();
}
else
if
(
type_name
.
compare
(
"Ellipsis"
)
==
0
)
{
type
=
std
::
make_shared
<
Ellipsis
>
();
type
=
std
::
make_shared
<
Type
Ellipsis
>
();
}
else
if
(
type_name
.
compare
(
"TypeType"
)
==
0
)
{
type
=
std
::
make_shared
<
TypeType
>
();
}
else
if
(
type_name
.
compare
(
"SymbolicKeyType"
)
==
0
)
{
...
...
@@ -476,7 +494,7 @@ REGISTER_PYBIND_DEFINE(
(
void
)
py
::
class_
<
RefType
,
Type
,
std
::
shared_ptr
<
RefType
>>
(
m_sub
,
"RefType"
).
def
(
py
::
init
());
(
void
)
py
::
class_
<
TypeAnything
,
Type
,
std
::
shared_ptr
<
TypeAnything
>>
(
m_sub
,
"TypeAnything"
).
def
(
py
::
init
());
(
void
)
py
::
class_
<
Slice
,
Type
,
std
::
shared_ptr
<
Slice
>>
(
m_sub
,
"Slice"
).
def
(
py
::
init
());
(
void
)
py
::
class_
<
Ellipsis
,
Type
,
std
::
shared_ptr
<
Ellipsis
>>
(
m_sub
,
"
Ellipsis"
).
def
(
py
::
init
());
(
void
)
py
::
class_
<
TypeEllipsis
,
Type
,
std
::
shared_ptr
<
TypeEllipsis
>>
(
m_sub
,
"Type
Ellipsis"
).
def
(
py
::
init
());
}));
const
TypePtr
kTypeExternal
=
std
::
make_shared
<
External
>
();
...
...
@@ -484,4 +502,9 @@ const TypePtr kTypeEnv = std::make_shared<EnvType>();
const
TypePtr
kTypeType
=
std
::
make_shared
<
TypeType
>
();
const
TypePtr
kTensorType
=
std
::
make_shared
<
TensorType
>
();
const
TypePtr
kString
=
std
::
make_shared
<
String
>
();
const
TypePtr
kList
=
std
::
make_shared
<
List
>
();
const
TypePtr
kTuple
=
std
::
make_shared
<
Tuple
>
();
const
TypePtr
kDict
=
std
::
make_shared
<
Dictionary
>
();
const
TypePtr
kSlice
=
std
::
make_shared
<
Slice
>
();
const
TypePtr
kKeyword
=
std
::
make_shared
<
Keyword
>
();
}
// namespace mindspore
mindspore/ccsrc/ir/func_graph.cc
浏览文件 @
fe8f47dc
...
...
@@ -432,7 +432,7 @@ AnfNodePtr FuncGraph::GetDefaultValueByName(const std::string &name) {
if
(
default_value
==
nullptr
)
{
MS_LOG
(
EXCEPTION
)
<<
"Graph parameter "
<<
name
<<
" not exist"
;
}
if
(
IsValueNode
<
Null
Obj
>
(
default_value
))
{
if
(
IsValueNode
<
Null
>
(
default_value
))
{
return
nullptr
;
}
return
default_value
;
...
...
@@ -440,8 +440,8 @@ AnfNodePtr FuncGraph::GetDefaultValueByName(const std::string &name) {
// set the default values
void
FuncGraph
::
SetDefaultValues
(
const
std
::
vector
<
std
::
string
>
&
name_list
,
const
std
::
vector
<
AnfNodePtr
>
&
value_list
)
{
auto
all_is_null
=
std
::
all_of
(
value_list
.
begin
(),
value_list
.
end
(),
[](
const
AnfNodePtr
&
node
)
{
return
IsValueNode
<
NullObj
>
(
node
);
});
auto
all_is_null
=
std
::
all_of
(
value_list
.
begin
(),
value_list
.
end
(),
[](
const
AnfNodePtr
&
node
)
{
return
IsValueNode
<
Null
>
(
node
);
});
if
(
value_list
.
empty
())
{
all_is_null
=
true
;
}
...
...
@@ -457,7 +457,7 @@ void FuncGraph::ClearDefaultValues() { parameter_default_value_.clear(); }
size_t
FuncGraph
::
GetDefaultValueCount
()
{
int
null_count
=
std
::
count_if
(
parameter_default_value_
.
begin
(),
parameter_default_value_
.
end
(),
[](
const
std
::
pair
<
std
::
string
,
AnfNodePtr
>
&
pair
)
{
return
IsValueNode
<
Null
Obj
>
(
pair
.
second
);
});
[](
const
std
::
pair
<
std
::
string
,
AnfNodePtr
>
&
pair
)
{
return
IsValueNode
<
Null
>
(
pair
.
second
);
});
return
parameter_default_value_
.
size
()
-
IntToSize
(
null_count
);
}
...
...
mindspore/ccsrc/ir/named.cc
浏览文件 @
fe8f47dc
...
...
@@ -30,9 +30,9 @@ bool Named::operator==(const Value &other) const {
abstract
::
AbstractBasePtr
None
::
ToAbstract
()
{
return
std
::
make_shared
<
abstract
::
AbstractNone
>
();
}
const
NamedPtr
kNone
=
std
::
make_shared
<
None
>
();
abstract
::
AbstractBasePtr
Null
Obj
::
ToAbstract
()
{
return
std
::
make_shared
<
abstract
::
AbstractNull
>
();
}
const
NamedPtr
kNull
=
std
::
make_shared
<
Null
Obj
>
();
abstract
::
AbstractBasePtr
Null
::
ToAbstract
()
{
return
std
::
make_shared
<
abstract
::
AbstractNull
>
();
}
const
NamedPtr
kNull
=
std
::
make_shared
<
Null
>
();
abstract
::
AbstractBasePtr
Ellipsis
Obj
::
ToAbstract
()
{
return
std
::
make_shared
<
abstract
::
AbstractEllipsis
>
();
}
const
NamedPtr
kEllipsis
=
std
::
make_shared
<
Ellipsis
Obj
>
();
abstract
::
AbstractBasePtr
Ellipsis
::
ToAbstract
()
{
return
std
::
make_shared
<
abstract
::
AbstractEllipsis
>
();
}
const
NamedPtr
kEllipsis
=
std
::
make_shared
<
Ellipsis
>
();
}
// namespace mindspore
mindspore/ccsrc/ir/named.h
浏览文件 @
fe8f47dc
...
...
@@ -71,20 +71,20 @@ class None : public Named {
};
extern
const
NamedPtr
kNone
;
class
Null
Obj
:
public
Named
{
class
Null
:
public
Named
{
public:
Null
Obj
()
:
Named
(
"Null"
)
{}
~
Null
Obj
()
override
=
default
;
MS_DECLARE_PARENT
(
Null
Obj
,
Named
);
Null
()
:
Named
(
"Null"
)
{}
~
Null
()
override
=
default
;
MS_DECLARE_PARENT
(
Null
,
Named
);
abstract
::
AbstractBasePtr
ToAbstract
()
override
;
};
extern
const
NamedPtr
kNull
;
class
Ellipsis
Obj
:
public
Named
{
class
Ellipsis
:
public
Named
{
public:
Ellipsis
Obj
()
:
Named
(
"Ellipsis"
)
{}
~
Ellipsis
Obj
()
override
=
default
;
MS_DECLARE_PARENT
(
Ellipsis
Obj
,
Named
);
Ellipsis
()
:
Named
(
"Ellipsis"
)
{}
~
Ellipsis
()
override
=
default
;
MS_DECLARE_PARENT
(
Ellipsis
,
Named
);
abstract
::
AbstractBasePtr
ToAbstract
()
override
;
};
extern
const
NamedPtr
kEllipsis
;
...
...
mindspore/ccsrc/pipeline/static_analysis/abstract_value.h
浏览文件 @
fe8f47dc
...
...
@@ -515,11 +515,11 @@ using AbstractNullPtr = std::shared_ptr<AbstractNull>;
class
AbstractEllipsis
:
public
AbstractBase
{
public:
AbstractEllipsis
()
:
AbstractBase
(
kEllipsis
)
{
set_type
(
std
::
make_shared
<
Ellipsis
>
());
}
AbstractEllipsis
()
:
AbstractBase
(
kEllipsis
)
{
set_type
(
std
::
make_shared
<
Type
Ellipsis
>
());
}
~
AbstractEllipsis
()
override
=
default
;
MS_DECLARE_PARENT
(
AbstractEllipsis
,
AbstractBase
)
TypePtr
BuildType
()
const
override
{
return
std
::
make_shared
<
Ellipsis
>
();
}
TypePtr
BuildType
()
const
override
{
return
std
::
make_shared
<
Type
Ellipsis
>
();
}
bool
operator
==
(
const
AbstractEllipsis
&
other
)
const
;
bool
operator
==
(
const
AbstractBase
&
other
)
const
override
;
AbstractBasePtr
Clone
()
const
override
{
return
std
::
make_shared
<
AbstractEllipsis
>
();
}
...
...
mindspore/ccsrc/utils/convert_utils.cc
浏览文件 @
fe8f47dc
...
...
@@ -105,7 +105,7 @@ py::object ValuePtrToPyData(const ValuePtr &value) {
i
++
;
}
ret
=
rets
;
}
else
if
(
value
->
isa
<
Ellipsis
Obj
>
())
{
}
else
if
(
value
->
isa
<
Ellipsis
>
())
{
ret
=
py
::
ellipsis
();
}
else
if
(
value
->
isa
<
ValueSlice
>
())
{
auto
slice
=
value
->
cast
<
ValueSlicePtr
>
();
...
...
mindspore/common/dtype.py
浏览文件 @
fe8f47dc
...
...
@@ -96,7 +96,7 @@ type_refkey = typing.RefKeyType()
tensor_type
=
typing
.
TensorType
anything_type
=
typing
.
TypeAnything
slice_type
=
typing
.
Slice
ellipsis_type
=
typing
.
Ellipsis
ellipsis_type
=
typing
.
Type
Ellipsis
number_type
=
(
int8
,
int16
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录