Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9d7c48d9
提交
9d7c48d9
authored
5月 23, 2015
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Flake8 for gof/vm.py
上级
6d034f05
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
34 行增加
和
25 行删除
+34
-25
vm.py
theano/gof/vm.py
+34
-24
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/vm.py
浏览文件 @
9d7c48d9
...
...
@@ -53,7 +53,8 @@ AddConfigVar('vm.lazy',
in_c_key
=
False
)
def
calculate_reallocate_info
(
order
,
fgraph
,
storage_map
,
compute_map_re
,
dependencies
):
def
calculate_reallocate_info
(
order
,
fgraph
,
storage_map
,
compute_map_re
,
dependencies
):
reallocated_info
=
{}
viewed_by
=
{}
for
var
in
fgraph
.
variables
:
...
...
@@ -74,14 +75,14 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
ins
=
None
if
dmap
and
idx_o
in
dmap
:
idx_v
=
dmap
[
idx_o
]
assert
len
(
idx_v
)
==
1
,
"Here we only support the possibility to destroy one input"
assert
len
(
idx_v
)
==
1
,
(
"Here we only support the possibility"
" to destroy one input"
)
ins
=
node
.
inputs
[
idx_v
[
0
]]
if
vmap
and
idx_o
in
vmap
:
assert
ins
is
None
idx_v
=
vmap
[
idx_o
]
assert
len
(
idx_v
)
==
1
,
"Here we only support the possibility to view one input"
assert
len
(
idx_v
)
==
1
,
(
"Here we only support the possibility"
" to view one input"
)
ins
=
node
.
inputs
[
idx_v
[
0
]]
if
ins
is
not
None
:
assert
isinstance
(
ins
,
theano
.
Variable
)
...
...
@@ -94,7 +95,8 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
assert
not
(
ins
in
view_of
and
viewed_by
[
ins
])
if
(
getattr
(
ins
,
'ndim'
,
None
)
==
0
and
not
storage_map
[
ins
][
0
]
and
ins
not
in
fgraph
.
outputs
and
ins
.
owner
and
all
([
compute_map_re
[
v
][
0
]
for
v
in
dependencies
.
get
(
ins
,
[])])
and
all
([
compute_map_re
[
v
][
0
]
for
v
in
dependencies
.
get
(
ins
,
[])])
and
ins
not
in
allocated
):
# Constant Memory cannot be changed
# Constant and shared variables' storage_map value is not empty
...
...
@@ -105,8 +107,9 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
if
reuse_out
:
break
for
out
in
order
[
i
]
.
outputs
:
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
reuse_out
=
out
pre_allocated
.
add
(
out
)
allocated
.
add
(
ins
)
...
...
@@ -122,8 +125,9 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
if
reuse_out
:
break
for
out
in
order
[
i
]
.
outputs
:
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
reuse_out
=
out
pre_allocated
.
add
(
out
)
allocated
.
add
(
ins
)
...
...
@@ -508,9 +512,10 @@ class Stack(VM):
st
=
"c"
self
.
variable_strides
[
var
]
=
st
except
Exception
:
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
for
o
in
current_apply
.
outputs
:
compute_map
[
o
][
0
]
=
1
...
...
@@ -544,10 +549,13 @@ class Stack(VM):
'destroy_map'
,
False
)):
warnings
.
warn
(
"There was a bug that existed in the default Theano configuration,"
" only in the development version between July 5th 2012"
" and July 30th 2012. This was not in a released version."
" The bug was affecting this script."
,
"There was a bug that existed in "
"the default Theano configuration,"
" only in the development version "
"between July 5th 2012 and "
"July 30th 2012. This was not in "
"a released version. The bug was "
"affecting this script."
,
# The stack level is not good when
# inside a Scan.
stacklevel
=
3
...
...
@@ -578,9 +586,10 @@ class Stack(VM):
self
.
call_times
[
current_idx
]
+=
dt
except
Exception
:
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
if
requires
:
for
r
in
requires
:
...
...
@@ -639,7 +648,7 @@ class Stack(VM):
if
self
.
allow_gc
:
for
v
in
storage_map
:
if
v
.
owner
and
not
v
in
self
.
outputs
:
if
v
.
owner
and
v
not
in
self
.
outputs
:
if
compute_map
[
v
][
0
]
==
2
:
continue
else
:
...
...
@@ -840,7 +849,6 @@ class VM_Linker(link.LocalLinker):
vars_idx_inv
[
i
]
=
var
# put storage_map and compute_map into a int-based scheme
n_applies
=
len
(
nodes
)
storage_map_list
=
[
storage_map
[
vars_idx_inv
[
i
]]
for
i
in
xrange
(
len
(
vars_idx_inv
))]
compute_map_list
=
[
compute_map
[
vars_idx_inv
[
i
]]
...
...
@@ -988,7 +996,8 @@ class VM_Linker(link.LocalLinker):
else
:
dependencies
=
self
.
compute_gc_dependencies
(
storage_map
)
reallocated_info
=
calculate_reallocate_info
(
order
,
fgraph
,
storage_map
,
compute_map_re
,
dependencies
)
reallocated_info
=
calculate_reallocate_info
(
order
,
fgraph
,
storage_map
,
compute_map_re
,
dependencies
)
for
node
in
order
:
try
:
...
...
@@ -1014,7 +1023,8 @@ class VM_Linker(link.LocalLinker):
lazy
=
config
.
vm
.
lazy
if
lazy
is
None
:
lazy
=
not
all
([(
not
th
.
lazy
)
for
th
in
thunks
])
if
not
(
lazy
or
(
config
.
profile
and
config
.
profile_memory
)
or
self
.
use_cloop
or
self
.
callback
):
if
not
(
lazy
or
(
config
.
profile
and
config
.
profile_memory
)
or
self
.
use_cloop
or
self
.
callback
):
for
pair
in
reallocated_info
.
values
():
storage_map
[
pair
[
1
]]
=
storage_map
[
pair
[
0
]]
...
...
theano/tests/test_flake8.py
浏览文件 @
9d7c48d9
...
...
@@ -268,7 +268,6 @@ whitelist_flake8 = [
"sparse/sandbox/truedot.py"
,
"sparse/sandbox/sp.py"
,
"gof/destroyhandler.py"
,
"gof/vm.py"
,
"gof/cutils.py"
,
"gof/compiledir.py"
,
"gof/unify.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论