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?"""
if
c
.
required
:
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
if
getattr
(
self
.
fn
,
'allow_gc'
,
False
):
assert
len
(
self
.
output_storage
)
==
len
(
self
.
maker
.
fgraph
.
outputs
)
...
...
theano/gof/destroyhandler.py
浏览文件 @
944e36dd
...
...
@@ -291,8 +291,6 @@ if 0:
####### Do the checking ###########
already_there
=
False
if
self
.
fgraph
is
fgraph
:
already_there
=
True
if
self
.
fgraph
not
in
[
None
,
fgraph
]:
raise
Exception
(
"A DestroyHandler instance can only serve"
" one FunctionGraph. (Matthew 6:24)"
)
...
...
@@ -796,12 +794,11 @@ class DestroyHandler(toolbox.Bookkeeper):
# 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
getattr
(
app
.
op
,
'destroy_map'
,
OrderedDict
()
):
if
getattr
(
app
.
op
,
'destroy_map'
,
{}
):
self
.
destroyers
.
add
(
app
)
# add this symbol to the forward and backward maps
for
o_idx
,
i_idx_list
in
getattr
(
app
.
op
,
'view_map'
,
OrderedDict
())
.
items
():
for
o_idx
,
i_idx_list
in
getattr
(
app
.
op
,
'view_map'
,
{})
.
items
():
if
len
(
i_idx_list
)
>
1
:
raise
NotImplementedError
(
'destroying this output invalidates multiple inputs'
,
...
...
theano/gof/link.py
浏览文件 @
944e36dd
...
...
@@ -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.
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
last_user
=
{}
...
...
theano/gof/vm.py
浏览文件 @
944e36dd
...
...
@@ -378,8 +378,8 @@ class Stack(VM):
# destroy_dependencies
# --------------------
# The destroy_dependencies is a list of variables that are implicit
# dependencies induced by
a destroy_map (compare node.inputs which
# are *explicit* dependencies). The variables in
# dependencies induced by
destroy_map and view_map (compared to
#
node.inputs which
are *explicit* dependencies). The variables in
# destroy_dependencies would be impossible to compute after the
# current `node` runs, because node.thunk() is going to destroy a
# common input variable needed by whatever node owns each variable
...
...
@@ -787,6 +787,12 @@ class VM_Linker(link.LocalLinker):
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
=
{}
for
k
in
variables
:
...
...
@@ -796,6 +802,9 @@ class VM_Linker(link.LocalLinker):
# way of getting it back.
#
# 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
:
ls
=
[]
for
cl
in
k
.
clients
:
...
...
theano/tensor/blas_c.py
浏览文件 @
944e36dd
...
...
@@ -730,7 +730,9 @@ def check_force_gemv_init():
f
=
theano
.
function
(
[
aa
,
yy
,
xx
],
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
:
theano
.
config
.
compute_test_value
=
tv
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
944e36dd
...
...
@@ -315,6 +315,12 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
n
=
self
.
shared
(
numpy
.
arange
(
12
,
dtype
=
self
.
dtype
)
.
reshape
((
4
,
3
)))
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
):
"""
newaxis support comes from logic in the __getitem__ of TensorType
...
...
theano/tensor/var.py
浏览文件 @
944e36dd
...
...
@@ -355,7 +355,10 @@ class _tensor_py_operators:
# SLICING/INDEXING
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
,
# Convert python literals to theano constants
args
=
theano
.
tensor
.
subtensor
.
make_constant
(
args
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论