Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
db94c5fb
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看板
提交
db94c5fb
编写于
7月 01, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
7月 01, 2020
浏览文件
操作
浏览文件
下载
差异文件
!2786 Optimization for ast_cache
Merge pull request !2786 from Kang/optimization
上级
929fe39d
f797d17a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
3 addition
and
13 deletion
+3
-13
mindspore/_extends/parse/parser.py
mindspore/_extends/parse/parser.py
+2
-12
mindspore/ccsrc/optimizer/optimizer.h
mindspore/ccsrc/optimizer/optimizer.h
+1
-1
未找到文件。
mindspore/_extends/parse/parser.py
浏览文件 @
db94c5fb
...
@@ -345,16 +345,6 @@ class Parser:
...
@@ -345,16 +345,6 @@ class Parser:
self
.
function_name
=
fn
.
__name__
self
.
function_name
=
fn
.
__name__
self
.
col_offset
=
0
self
.
col_offset
=
0
@
classmethod
def
get_cache
(
cls
,
key
):
"""Get the value of the ast_cache dictionary"""
return
cls
.
ast_cache
.
get
(
key
)
@
classmethod
def
insert_cache
(
cls
,
key
,
value
):
"""Insert elements to the ast_cache dictionary"""
cls
.
ast_cache
[
key
]
=
value
def
parse
(
self
):
def
parse
(
self
):
"""Parse the function or method."""
"""Parse the function or method."""
logger
.
debug
(
"fn = %r"
,
self
.
fn
)
logger
.
debug
(
"fn = %r"
,
self
.
fn
)
...
@@ -362,14 +352,14 @@ class Parser:
...
@@ -362,14 +352,14 @@ class Parser:
if
isinstance
(
self
.
fn
,
(
types
.
FunctionType
,
types
.
MethodType
)):
if
isinstance
(
self
.
fn
,
(
types
.
FunctionType
,
types
.
MethodType
)):
original_src
=
inspect
.
getsource
(
self
.
fn
)
original_src
=
inspect
.
getsource
(
self
.
fn
)
hexstr
=
hashlib
.
sha256
(
original_src
.
encode
()).
hexdigest
()
hexstr
=
hashlib
.
sha256
(
original_src
.
encode
()).
hexdigest
()
tree
=
Parser
.
get_cache
(
hexstr
)
tree
=
Parser
.
ast_cache
.
get
(
hexstr
)
if
not
tree
:
if
not
tree
:
src
=
dedent
(
original_src
)
src
=
dedent
(
original_src
)
self
.
col_offset
=
\
self
.
col_offset
=
\
len
(
original_src
.
split
(
'
\n
'
)[
0
])
-
len
(
src
.
split
(
'
\n
'
)[
0
])
len
(
original_src
.
split
(
'
\n
'
)[
0
])
-
len
(
src
.
split
(
'
\n
'
)[
0
])
logger
.
debug
(
"get source = %s"
,
src
)
logger
.
debug
(
"get source = %s"
,
src
)
tree
=
asttokens
.
ASTTokens
(
src
,
parse
=
True
).
tree
tree
=
asttokens
.
ASTTokens
(
src
,
parse
=
True
).
tree
Parser
.
insert_cache
(
hexstr
,
tree
)
Parser
.
ast_cache
[
hexstr
]
=
tree
else
:
else
:
logger
.
error
(
"Fn type is invalid"
)
logger
.
error
(
"Fn type is invalid"
)
return
tree
return
tree
...
...
mindspore/ccsrc/optimizer/optimizer.h
浏览文件 @
db94c5fb
...
@@ -136,7 +136,7 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
...
@@ -136,7 +136,7 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
return
func_graph
;
return
func_graph
;
}
}
// Optimizer step counter;
// Optimizer step counter;
int
counter
=
-
1
;
int
counter
=
1
;
bool
changes
=
true
;
bool
changes
=
true
;
while
(
changes
)
{
while
(
changes
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录