Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
535f3992
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看板
提交
535f3992
编写于
7月 09, 2020
作者:
H
He Wei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Decouple ir.Signature from python
上级
b4e37158
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
32 deletion
+19
-32
mindspore/ccsrc/ir/primitive.cc
mindspore/ccsrc/ir/primitive.cc
+11
-7
mindspore/ccsrc/ir/signature.h
mindspore/ccsrc/ir/signature.h
+5
-6
mindspore/ccsrc/ir/signature_py.cc
mindspore/ccsrc/ir/signature_py.cc
+3
-19
未找到文件。
mindspore/ccsrc/ir/primitive.cc
浏览文件 @
535f3992
...
...
@@ -30,17 +30,21 @@
#include "pybind_api/export_flags.h"
namespace
mindspore
{
static
ValuePtr
PyArgToValue
(
const
py
::
object
&
arg
)
{
if
(
py
::
isinstance
<
SignatureEnumKind
>
(
arg
)
&&
py
::
cast
<
SignatureEnumKind
>
(
arg
)
==
SignatureEnumKind
::
kKindEmptyDefaultValue
)
{
return
nullptr
;
}
return
parse
::
data_converter
::
PyDataToValue
(
arg
);
}
void
PrimitivePy
::
set_signatures
(
std
::
vector
<
std
::
tuple
<
std
::
string
,
SignatureEnumRW
,
SignatureEnumKind
,
py
::
object
,
SignatureEnumDType
>>
signatures
)
{
signatures_
.
clear
();
for
(
auto
&
signature
:
signatures
)
{
std
::
string
name
;
SignatureEnumRW
rw
;
SignatureEnumKind
kind
;
py
::
object
default_value
;
SignatureEnumDType
dtype
;
std
::
tie
(
name
,
rw
,
kind
,
default_value
,
dtype
)
=
signature
;
signatures_
.
emplace_back
(
Signature
(
name
,
rw
,
kind
,
default_value
,
dtype
));
auto
[
name
,
rw
,
kind
,
arg_default
,
dtype
]
=
signature
;
auto
default_value
=
PyArgToValue
(
arg_default
);
signatures_
.
emplace_back
(
name
,
rw
,
kind
,
default_value
,
dtype
);
}
set_has_signature
(
true
);
}
...
...
mindspore/ccsrc/ir/signature.h
浏览文件 @
535f3992
...
...
@@ -16,14 +16,11 @@
#ifndef MINDSPORE_CCSRC_IR_SIGNATURE_H_
#define MINDSPORE_CCSRC_IR_SIGNATURE_H_
#include <string>
#include <vector>
#include "pybind11/operators.h"
#include "ir/value.h"
namespace
py
=
pybind11
;
namespace
mindspore
{
// Input signature, support type
enum
SignatureEnumRW
{
...
...
@@ -62,8 +59,10 @@ struct Signature {
ValuePtr
default_value
;
// nullptr for no default value
SignatureEnumDType
dtype
;
Signature
(
const
std
::
string
&
arg_name
,
const
SignatureEnumRW
&
rw_tag
,
const
SignatureEnumKind
&
arg_kind
,
const
py
::
object
&
arg_default
,
const
SignatureEnumDType
&
arg_dtype
);
Signature
(
const
std
::
string
&
arg_name
,
const
SignatureEnumRW
&
rw_tag
,
const
SignatureEnumKind
&
arg_kind
);
const
ValuePtr
&
arg_default
,
const
SignatureEnumDType
&
arg_dtype
)
:
name
(
arg_name
),
rw
(
rw_tag
),
kind
(
arg_kind
),
default_value
(
arg_default
),
dtype
(
arg_dtype
)
{}
Signature
(
const
std
::
string
&
arg_name
,
const
SignatureEnumRW
&
rw_tag
,
const
SignatureEnumKind
&
arg_kind
)
:
Signature
(
arg_name
,
rw_tag
,
arg_kind
,
nullptr
,
SignatureEnumDType
::
kDTypeEmptyDefaultValue
)
{}
};
}
// namespace mindspore
...
...
mindspore/ccsrc/ir/signature.cc
→
mindspore/ccsrc/ir/signature
_py
.cc
浏览文件 @
535f3992
...
...
@@ -15,30 +15,14 @@
*/
#include "ir/signature.h"
#include "pybind11/operators.h"
#include "pybind_api/api_register.h"
#include "pipeline/parse/data_converter.h"
namespace
mindspore
{
Signature
::
Signature
(
const
std
::
string
&
arg_name
,
const
SignatureEnumRW
&
rw_tag
,
const
SignatureEnumKind
&
arg_kind
,
const
py
::
object
&
arg_default
,
const
SignatureEnumDType
&
arg_dtype
)
:
name
(
arg_name
),
rw
(
rw_tag
),
kind
(
arg_kind
),
dtype
(
arg_dtype
)
{
if
(
py
::
isinstance
<
SignatureEnumKind
>
(
arg_default
)
&&
py
::
cast
<
SignatureEnumKind
>
(
arg_default
)
==
SignatureEnumKind
::
kKindEmptyDefaultValue
)
{
default_value
=
nullptr
;
}
else
{
default_value
=
parse
::
data_converter
::
PyDataToValue
(
arg_default
);
}
}
Signature
::
Signature
(
const
std
::
string
&
arg_name
,
const
SignatureEnumRW
&
rw_tag
,
const
SignatureEnumKind
&
arg_kind
)
:
name
(
arg_name
),
rw
(
rw_tag
),
kind
(
arg_kind
),
default_value
(
nullptr
),
dtype
(
SignatureEnumDType
::
kDTypeEmptyDefaultValue
)
{}
namespace
py
=
pybind11
;
namespace
mindspore
{
// Bind SignatureEnumRW as a python class.
REGISTER_PYBIND_DEFINE
(
SignatureEnumRW
,
([](
const
py
::
module
*
m
)
{
(
void
)
py
::
enum_
<
SignatureEnumRW
>
(
*
m
,
"signature_rw"
,
py
::
arithmetic
())
.
value
(
"RW_READ"
,
SignatureEnumRW
::
kRWRead
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录