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 个修改的文件
包含
30 行增加
和
21 行删除
+30
-21
vm.py
theano/gof/vm.py
+30
-20
test_flake8.py
theano/tests/test_flake8.py
+0
-1
没有找到文件。
theano/gof/vm.py
浏览文件 @
9d7c48d9
...
@@ -53,7 +53,8 @@ AddConfigVar('vm.lazy',
...
@@ -53,7 +53,8 @@ AddConfigVar('vm.lazy',
in_c_key
=
False
)
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
=
{}
reallocated_info
=
{}
viewed_by
=
{}
viewed_by
=
{}
for
var
in
fgraph
.
variables
:
for
var
in
fgraph
.
variables
:
...
@@ -74,14 +75,14 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
...
@@ -74,14 +75,14 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
ins
=
None
ins
=
None
if
dmap
and
idx_o
in
dmap
:
if
dmap
and
idx_o
in
dmap
:
idx_v
=
dmap
[
idx_o
]
idx_v
=
dmap
[
idx_o
]
assert
len
(
assert
len
(
idx_v
)
==
1
,
(
"Here we only support the possibility"
idx_v
)
==
1
,
"Here we only support the possibility to destroy one input"
" to destroy one input"
)
ins
=
node
.
inputs
[
idx_v
[
0
]]
ins
=
node
.
inputs
[
idx_v
[
0
]]
if
vmap
and
idx_o
in
vmap
:
if
vmap
and
idx_o
in
vmap
:
assert
ins
is
None
assert
ins
is
None
idx_v
=
vmap
[
idx_o
]
idx_v
=
vmap
[
idx_o
]
assert
len
(
assert
len
(
idx_v
)
==
1
,
(
"Here we only support the possibility"
idx_v
)
==
1
,
"Here we only support the possibility to view one input"
" to view one input"
)
ins
=
node
.
inputs
[
idx_v
[
0
]]
ins
=
node
.
inputs
[
idx_v
[
0
]]
if
ins
is
not
None
:
if
ins
is
not
None
:
assert
isinstance
(
ins
,
theano
.
Variable
)
assert
isinstance
(
ins
,
theano
.
Variable
)
...
@@ -94,7 +95,8 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
...
@@ -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
])
assert
not
(
ins
in
view_of
and
viewed_by
[
ins
])
if
(
getattr
(
ins
,
'ndim'
,
None
)
==
0
and
not
storage_map
[
ins
][
0
]
if
(
getattr
(
ins
,
'ndim'
,
None
)
==
0
and
not
storage_map
[
ins
][
0
]
and
ins
not
in
fgraph
.
outputs
and
ins
.
owner
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
):
and
ins
not
in
allocated
):
# Constant Memory cannot be changed
# Constant Memory cannot be changed
# Constant and shared variables' storage_map value is not empty
# 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
...
@@ -105,8 +107,9 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
if
reuse_out
:
if
reuse_out
:
break
break
for
out
in
order
[
i
]
.
outputs
:
for
out
in
order
[
i
]
.
outputs
:
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
and
ins
.
type
==
out
.
type
):
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
reuse_out
=
out
reuse_out
=
out
pre_allocated
.
add
(
out
)
pre_allocated
.
add
(
out
)
allocated
.
add
(
ins
)
allocated
.
add
(
ins
)
...
@@ -122,8 +125,9 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
...
@@ -122,8 +125,9 @@ def calculate_reallocate_info(order, fgraph, storage_map, compute_map_re, depend
if
reuse_out
:
if
reuse_out
:
break
break
for
out
in
order
[
i
]
.
outputs
:
for
out
in
order
[
i
]
.
outputs
:
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
out
not
in
pre_allocated
if
(
getattr
(
out
,
'ndim'
,
None
)
==
0
and
and
ins
.
type
==
out
.
type
):
out
not
in
pre_allocated
and
ins
.
type
==
out
.
type
):
reuse_out
=
out
reuse_out
=
out
pre_allocated
.
add
(
out
)
pre_allocated
.
add
(
out
)
allocated
.
add
(
ins
)
allocated
.
add
(
ins
)
...
@@ -508,7 +512,8 @@ class Stack(VM):
...
@@ -508,7 +512,8 @@ class Stack(VM):
st
=
"c"
st
=
"c"
self
.
variable_strides
[
var
]
=
st
self
.
variable_strides
[
var
]
=
st
except
Exception
:
except
Exception
:
link
.
raise_with_op
(
current_apply
,
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
storage_map
=
storage_map
)
for
o
in
current_apply
.
outputs
:
for
o
in
current_apply
.
outputs
:
...
@@ -544,10 +549,13 @@ class Stack(VM):
...
@@ -544,10 +549,13 @@ class Stack(VM):
'destroy_map'
,
'destroy_map'
,
False
)):
False
)):
warnings
.
warn
(
warnings
.
warn
(
"There was a bug that existed in the default Theano configuration,"
"There was a bug that existed in "
" only in the development version between July 5th 2012"
"the default Theano configuration,"
" and July 30th 2012. This was not in a released version."
" only in the development version "
" The bug was affecting this script."
,
"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
# The stack level is not good when
# inside a Scan.
# inside a Scan.
stacklevel
=
3
stacklevel
=
3
...
@@ -578,7 +586,8 @@ class Stack(VM):
...
@@ -578,7 +586,8 @@ class Stack(VM):
self
.
call_times
[
current_idx
]
+=
dt
self
.
call_times
[
current_idx
]
+=
dt
except
Exception
:
except
Exception
:
link
.
raise_with_op
(
current_apply
,
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
storage_map
=
storage_map
)
...
@@ -639,7 +648,7 @@ class Stack(VM):
...
@@ -639,7 +648,7 @@ class Stack(VM):
if
self
.
allow_gc
:
if
self
.
allow_gc
:
for
v
in
storage_map
:
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
:
if
compute_map
[
v
][
0
]
==
2
:
continue
continue
else
:
else
:
...
@@ -840,7 +849,6 @@ class VM_Linker(link.LocalLinker):
...
@@ -840,7 +849,6 @@ class VM_Linker(link.LocalLinker):
vars_idx_inv
[
i
]
=
var
vars_idx_inv
[
i
]
=
var
# put storage_map and compute_map into a int-based scheme
# put storage_map and compute_map into a int-based scheme
n_applies
=
len
(
nodes
)
storage_map_list
=
[
storage_map
[
vars_idx_inv
[
i
]]
storage_map_list
=
[
storage_map
[
vars_idx_inv
[
i
]]
for
i
in
xrange
(
len
(
vars_idx_inv
))]
for
i
in
xrange
(
len
(
vars_idx_inv
))]
compute_map_list
=
[
compute_map
[
vars_idx_inv
[
i
]]
compute_map_list
=
[
compute_map
[
vars_idx_inv
[
i
]]
...
@@ -988,7 +996,8 @@ class VM_Linker(link.LocalLinker):
...
@@ -988,7 +996,8 @@ class VM_Linker(link.LocalLinker):
else
:
else
:
dependencies
=
self
.
compute_gc_dependencies
(
storage_map
)
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
:
for
node
in
order
:
try
:
try
:
...
@@ -1014,7 +1023,8 @@ class VM_Linker(link.LocalLinker):
...
@@ -1014,7 +1023,8 @@ class VM_Linker(link.LocalLinker):
lazy
=
config
.
vm
.
lazy
lazy
=
config
.
vm
.
lazy
if
lazy
is
None
:
if
lazy
is
None
:
lazy
=
not
all
([(
not
th
.
lazy
)
for
th
in
thunks
])
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
():
for
pair
in
reallocated_info
.
values
():
storage_map
[
pair
[
1
]]
=
storage_map
[
pair
[
0
]]
storage_map
[
pair
[
1
]]
=
storage_map
[
pair
[
0
]]
...
...
theano/tests/test_flake8.py
浏览文件 @
9d7c48d9
...
@@ -268,7 +268,6 @@ whitelist_flake8 = [
...
@@ -268,7 +268,6 @@ whitelist_flake8 = [
"sparse/sandbox/truedot.py"
,
"sparse/sandbox/truedot.py"
,
"sparse/sandbox/sp.py"
,
"sparse/sandbox/sp.py"
,
"gof/destroyhandler.py"
,
"gof/destroyhandler.py"
,
"gof/vm.py"
,
"gof/cutils.py"
,
"gof/cutils.py"
,
"gof/compiledir.py"
,
"gof/compiledir.py"
,
"gof/unify.py"
,
"gof/unify.py"
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论