Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
944e36dd
提交
944e36dd
authored
6月 04, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2992 from nouiz/subtensor_list
[CRASH] Subtensor list
上级
da3c4cd0
b172a19b
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
33 行增加
和
10 行删除
+33
-10
function_module.py
theano/compile/function_module.py
+1
-1
destroyhandler.py
theano/gof/destroyhandler.py
+2
-5
link.py
theano/gof/link.py
+6
-0
vm.py
theano/gof/vm.py
+11
-2
blas_c.py
theano/tensor/blas_c.py
+3
-1
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+6
-0
var.py
theano/tensor/var.py
+4
-1
没有找到文件。
theano/compile/function_module.py
浏览文件 @
944e36dd
...
@@ -640,7 +640,7 @@ returned directly?"""
...
@@ -640,7 +640,7 @@ returned directly?"""
if
c
.
required
:
if
c
.
required
:
c
.
storage
[
0
]
=
None
c
.
storage
[
0
]
=
None
# if we are allowing garbage collection, remove the
input and
# if we are allowing garbage collection, remove the
# output reference from the internal storage cells
# output reference from the internal storage cells
if
getattr
(
self
.
fn
,
'allow_gc'
,
False
):
if
getattr
(
self
.
fn
,
'allow_gc'
,
False
):
assert
len
(
self
.
output_storage
)
==
len
(
self
.
maker
.
fgraph
.
outputs
)
assert
len
(
self
.
output_storage
)
==
len
(
self
.
maker
.
fgraph
.
outputs
)
...
...
theano/gof/destroyhandler.py
浏览文件 @
944e36dd
...
@@ -291,8 +291,6 @@ if 0:
...
@@ -291,8 +291,6 @@ if 0:
####### Do the checking ###########
####### Do the checking ###########
already_there
=
False
already_there
=
False
if
self
.
fgraph
is
fgraph
:
already_there
=
True
if
self
.
fgraph
not
in
[
None
,
fgraph
]:
if
self
.
fgraph
not
in
[
None
,
fgraph
]:
raise
Exception
(
"A DestroyHandler instance can only serve"
raise
Exception
(
"A DestroyHandler instance can only serve"
" one FunctionGraph. (Matthew 6:24)"
)
" one FunctionGraph. (Matthew 6:24)"
)
...
@@ -796,12 +794,11 @@ class DestroyHandler(toolbox.Bookkeeper):
...
@@ -796,12 +794,11 @@ class DestroyHandler(toolbox.Bookkeeper):
# print 'DH IMPORT', app, id(app), id(self), len(self.debug_all_apps)
# print 'DH IMPORT', app, id(app), id(self), len(self.debug_all_apps)
# If it's a destructive op, add it to our watch list
# If it's a destructive op, add it to our watch list
if
getattr
(
app
.
op
,
'destroy_map'
,
OrderedDict
()
):
if
getattr
(
app
.
op
,
'destroy_map'
,
{}
):
self
.
destroyers
.
add
(
app
)
self
.
destroyers
.
add
(
app
)
# add this symbol to the forward and backward maps
# add this symbol to the forward and backward maps
for
o_idx
,
i_idx_list
in
getattr
(
app
.
op
,
'view_map'
,
for
o_idx
,
i_idx_list
in
getattr
(
app
.
op
,
'view_map'
,
{})
.
items
():
OrderedDict
())
.
items
():
if
len
(
i_idx_list
)
>
1
:
if
len
(
i_idx_list
)
>
1
:
raise
NotImplementedError
(
raise
NotImplementedError
(
'destroying this output invalidates multiple inputs'
,
'destroying this output invalidates multiple inputs'
,
...
...
theano/gof/link.py
浏览文件 @
944e36dd
...
@@ -624,6 +624,12 @@ def gc_helper(node_list):
...
@@ -624,6 +624,12 @@ def gc_helper(node_list):
dictionary that maps each Variable instance to a the last node to use Variable as an input.
dictionary that maps each Variable instance to a the last node to use Variable as an input.
This is used to allow garbage collection within graphs.
This is used to allow garbage collection within graphs.
It ignore view_map and destroy_map. This isn't needed as python
have referecence count. In Theano gc, we should not take into
account view_map and destroy_map as if the thunk decided to create
a new output, we would delay uselessly its gc by Python.
"""
"""
# for freeing memory
# for freeing memory
last_user
=
{}
last_user
=
{}
...
...
theano/gof/vm.py
浏览文件 @
944e36dd
...
@@ -378,8 +378,8 @@ class Stack(VM):
...
@@ -378,8 +378,8 @@ class Stack(VM):
# destroy_dependencies
# destroy_dependencies
# --------------------
# --------------------
# The destroy_dependencies is a list of variables that are implicit
# The destroy_dependencies is a list of variables that are implicit
# dependencies induced by
a destroy_map (compare node.inputs which
# dependencies induced by
destroy_map and view_map (compared to
# are *explicit* dependencies). The variables in
#
node.inputs which
are *explicit* dependencies). The variables in
# destroy_dependencies would be impossible to compute after the
# destroy_dependencies would be impossible to compute after the
# current `node` runs, because node.thunk() is going to destroy a
# current `node` runs, because node.thunk() is going to destroy a
# common input variable needed by whatever node owns each variable
# common input variable needed by whatever node owns each variable
...
@@ -787,6 +787,12 @@ class VM_Linker(link.LocalLinker):
...
@@ -787,6 +787,12 @@ class VM_Linker(link.LocalLinker):
N.B. gc means garbage collection
N.B. gc means garbage collection
Note
----
It don't take care of the view_map/destroy_map. So
it mean it rely on Python gc to don't free the object real
storage.
"""
"""
dependencies
=
{}
dependencies
=
{}
for
k
in
variables
:
for
k
in
variables
:
...
@@ -796,6 +802,9 @@ class VM_Linker(link.LocalLinker):
...
@@ -796,6 +802,9 @@ class VM_Linker(link.LocalLinker):
# way of getting it back.
# way of getting it back.
#
#
# XXX if k has no clients... what is it doing in the computation?
# XXX if k has no clients... what is it doing in the computation?
# Fred guess: it could happen for node with multiple outputs when
# we don't use all outputs.
if
k
.
owner
and
k
.
clients
:
if
k
.
owner
and
k
.
clients
:
ls
=
[]
ls
=
[]
for
cl
in
k
.
clients
:
for
cl
in
k
.
clients
:
...
...
theano/tensor/blas_c.py
浏览文件 @
944e36dd
...
@@ -730,7 +730,9 @@ def check_force_gemv_init():
...
@@ -730,7 +730,9 @@ def check_force_gemv_init():
f
=
theano
.
function
(
f
=
theano
.
function
(
[
aa
,
yy
,
xx
],
[
aa
,
yy
,
xx
],
gemv_no_inplace
(
aa
,
1.
,
xx
,
yy
,
0.
),
gemv_no_inplace
(
aa
,
1.
,
xx
,
yy
,
0.
),
theano
.
compile
.
Mode
(
optimizer
=
'fast_compile'
)
theano
.
compile
.
Mode
(
optimizer
=
'fast_compile'
)
.
excluding
(
'gpu'
,
'gpuarray'
),
profile
=
False
)
)
finally
:
finally
:
theano
.
config
.
compute_test_value
=
tv
theano
.
config
.
compute_test_value
=
tv
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
944e36dd
...
@@ -315,6 +315,12 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -315,6 +315,12 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
n
=
self
.
shared
(
numpy
.
arange
(
12
,
dtype
=
self
.
dtype
)
.
reshape
((
4
,
3
)))
n
=
self
.
shared
(
numpy
.
arange
(
12
,
dtype
=
self
.
dtype
)
.
reshape
((
4
,
3
)))
self
.
assertRaises
(
Exception
,
lambda
:
n
[:(
2L
**
63
)])
self
.
assertRaises
(
Exception
,
lambda
:
n
[:(
2L
**
63
)])
def
test_list_slice
(
self
):
x
=
theano
.
tensor
.
arange
(
100
)
.
reshape
((
5
,
5
,
4
))
res
=
x
[[
slice
(
1
,
-
1
)]
*
x
.
ndim
]
.
eval
()
x
=
numpy
.
arange
(
100
)
.
reshape
((
5
,
5
,
4
))
numpy
.
allclose
(
res
,
x
[[
slice
(
1
,
-
1
)]
*
x
.
ndim
])
def
test_newaxis
(
self
):
def
test_newaxis
(
self
):
"""
"""
newaxis support comes from logic in the __getitem__ of TensorType
newaxis support comes from logic in the __getitem__ of TensorType
...
...
theano/tensor/var.py
浏览文件 @
944e36dd
...
@@ -355,7 +355,10 @@ class _tensor_py_operators:
...
@@ -355,7 +355,10 @@ class _tensor_py_operators:
# SLICING/INDEXING
# SLICING/INDEXING
def
__getitem__
(
self
,
args
):
def
__getitem__
(
self
,
args
):
if
not
isinstance
(
args
,
tuple
):
if
(
isinstance
(
args
,
list
)
and
any
([
isinstance
(
a
,
slice
)
for
a
in
args
])):
pass
elif
not
isinstance
(
args
,
tuple
):
args
=
args
,
args
=
args
,
# Convert python literals to theano constants
# Convert python literals to theano constants
args
=
theano
.
tensor
.
subtensor
.
make_constant
(
args
)
args
=
theano
.
tensor
.
subtensor
.
make_constant
(
args
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论