Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
799e97dd
提交
799e97dd
authored
6月 17, 2014
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1920 from nouiz/fix_tests
Fix tests in buildbot and memory leak with allow_gc=False
上级
d82eb54a
65b1d1ed
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
70 行增加
和
55 行删除
+70
-55
test_profiling.py
theano/compile/tests/test_profiling.py
+26
-20
vm.py
theano/gof/vm.py
+7
-7
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+1
-1
opt.py
theano/tensor/opt.py
+2
-1
test_gc.py
theano/tensor/tests/test_gc.py
+34
-26
test_opt.py
theano/tensor/tests/test_opt.py
+0
-0
没有找到文件。
theano/compile/tests/test_profiling.py
浏览文件 @
799e97dd
...
...
@@ -6,26 +6,33 @@ import theano
import
theano.tensor
as
T
import
StringIO
def
test_profiling
():
old1
=
theano
.
config
.
profile
old2
=
theano
.
config
.
profile_memory
theano
.
config
.
profile
=
True
theano
.
config
.
profile_memory
=
True
x
=
T
.
dvector
(
"x"
)
y
=
T
.
dvector
(
"y"
)
z
=
x
+
y
f
=
theano
.
function
([
x
,
y
],
z
,
profile
=
True
,
name
=
"test_profiling"
)
output
=
f
([
1
,
2
,
3
,
4
],[
1
,
1
,
1
,
1
])
buf
=
StringIO
.
StringIO
()
f
.
profile
.
summary
(
buf
)
theano
.
config
.
profile
=
old1
theano
.
config
.
profile_memory
=
old2
old1
=
theano
.
config
.
profile
old2
=
theano
.
config
.
profile_memory
try
:
theano
.
config
.
profile
=
True
theano
.
config
.
profile_memory
=
True
x
=
T
.
dvector
(
"x"
)
y
=
T
.
dvector
(
"y"
)
z
=
x
+
y
p
=
theano
.
ProfileStats
(
False
)
if
theano
.
config
.
mode
in
[
"DebugMode"
,
"DEBUG_MODE"
]:
m
=
"FAST_RUN"
else
:
m
=
None
f
=
theano
.
function
([
x
,
y
],
z
,
profile
=
p
,
name
=
"test_profiling"
,
mode
=
m
)
output
=
f
([
1
,
2
,
3
,
4
],
[
1
,
1
,
1
,
1
])
buf
=
StringIO
.
StringIO
()
f
.
profile
.
summary
(
buf
)
finally
:
theano
.
config
.
profile
=
old1
theano
.
config
.
profile_memory
=
old2
if
__name__
==
'__main__'
:
test_profiling
()
\ No newline at end of file
test_profiling
()
theano/gof/vm.py
浏览文件 @
799e97dd
...
...
@@ -305,7 +305,7 @@ class Stack(VM):
t0
=
time
.
time
()
rval
=
self
.
thunks
[
idx
]()
self
.
node_executed_order
.
append
(
node
)
# Some thunks on some computers run faster than the granularity
# of the time.time clock.
# Profile output looks buggy if a node has run but takes 0 time.
...
...
@@ -313,11 +313,11 @@ class Stack(VM):
dt
=
max
(
time
.
time
()
-
t0
,
1e-10
)
if
self
.
callback
is
not
None
:
self
.
callback
(
node
=
node
,
thunk
=
self
.
thunks
[
idx
],
storage_map
=
self
.
storage_map
,
compute_map
=
self
.
compute_map
,
)
node
=
node
,
thunk
=
self
.
thunks
[
idx
],
storage_map
=
self
.
storage_map
,
compute_map
=
self
.
compute_map
,
)
return
rval
,
dt
def
__call__
(
self
):
...
...
@@ -327,7 +327,7 @@ class Stack(VM):
dependencies
=
self
.
dependencies
self
.
node_executed_order
=
[]
self
.
node_cleared_order
=
[]
for
k
in
self
.
storage_map
:
compute_map
[
k
][
0
]
=
(
k
.
owner
is
None
)
...
...
theano/sandbox/cuda/basic_ops.py
浏览文件 @
799e97dd
...
...
@@ -3289,7 +3289,7 @@ class GpuContiguous(GpuOp):
Py_INCREF(
%(z)
s);
} else if ((NULL ==
%(z)
s)"""
%
locals
()
for
i
in
xrange
(
len
(
node
.
inputs
[
0
]
.
type
.
broadcastable
)
):
for
i
in
xrange
(
node
.
inputs
[
0
]
.
type
.
ndim
):
str
+=
"
\n
|| (CudaNdarray_HOST_DIMS(
%(input)
s)[
%(i)
s] != CudaNdarray_HOST_DIMS(
%(z)
s)[
%(i)
s])"
%
locals
()
str
+=
"""
|| !CudaNdarray_is_c_contiguous(
%(z)
s))
...
...
theano/tensor/opt.py
浏览文件 @
799e97dd
...
...
@@ -1409,12 +1409,13 @@ class Assert(T.Op):
check
=
"
\n
"
.
join
(
check
)
return
"""
%(check)
s
Py_XDECREF(
%(out)
s);
%(out)
s =
%(value)
s;
Py_INCREF(
%(value)
s);
"""
%
locals
()
def
c_code_cache_version
(
self
):
return
(
1
,
0
)
return
(
1
,
1
)
def
infer_shape
(
self
,
node
,
input_shapes
):
return
[
input_shapes
[
0
]]
...
...
theano/tensor/tests/test_gc.py
浏览文件 @
799e97dd
...
...
@@ -20,30 +20,35 @@ def test_no_reuse():
return
assert
not
'should not get here'
def
test_gc_never_pickles_temporaries
():
x
=
T
.
dvector
()
#print >> sys.stderr, 'BUILDING GRAPH'
for
i
in
xrange
(
2
):
#
TODO: 30 causes like LONG compilation due to MERGE
if
i
:
for
i
in
xrange
(
2
):
#
TODO: 30 causes like LONG compilation due to MERGE
if
i
:
r
=
r
+
r
/
10
else
:
r
=
x
optimizer
=
None
optimizer
=
'fast_run'
optimizer
=
None
optimizer
=
'fast_run'
for
f_linker
,
g_linker
in
[
(
theano
.
PerformLinker
(
allow_gc
=
True
),
theano
.
PerformLinker
(
allow_gc
=
False
)),
(
theano
.
OpWiseCLinker
(
allow_gc
=
True
),
theano
.
OpWiseCLinker
(
allow_gc
=
False
))]:
(
theano
.
PerformLinker
(
allow_gc
=
True
),
theano
.
PerformLinker
(
allow_gc
=
False
)),
(
theano
.
OpWiseCLinker
(
allow_gc
=
True
),
theano
.
OpWiseCLinker
(
allow_gc
=
False
))]:
#f_linker has garbage collection
#g_linker has no garbage collection
#print >> sys.stderr, 'COMPILING'
f
=
theano
.
function
([
x
],
r
,
mode
=
theano
.
Mode
(
optimizer
=
optimizer
,
linker
=
f_linker
))
g
=
theano
.
function
([
x
],
r
,
mode
=
theano
.
Mode
(
optimizer
=
optimizer
,
linker
=
g_linker
))
f
=
theano
.
function
([
x
],
r
,
mode
=
theano
.
Mode
(
optimizer
=
optimizer
,
linker
=
f_linker
))
g
=
theano
.
function
([
x
],
r
,
mode
=
theano
.
Mode
(
optimizer
=
optimizer
,
linker
=
g_linker
))
len_pre_f
=
len
(
cPickle
.
dumps
(
f
))
len_pre_g
=
len
(
cPickle
.
dumps
(
g
))
...
...
@@ -55,21 +60,20 @@ def test_gc_never_pickles_temporaries():
def
a
(
fn
):
return
len
(
cPickle
.
dumps
(
fn
.
maker
))
assert
a
(
f
)
==
a
(
f
)
# some sanity checks on the pickling mechanism
assert
a
(
g
)
==
a
(
g
)
# some sanity checks on the pickling mechanism
assert
a
(
f
)
==
a
(
f
)
# some sanity checks on the pickling mechanism
assert
a
(
g
)
==
a
(
g
)
# some sanity checks on the pickling mechanism
def
b
(
fn
):
return
len
(
cPickle
.
dumps
(
theano
.
compile
.
function_module
.
_pickle_Function
(
fn
)))
assert
b
(
f
)
==
b
(
f
)
# some sanity checks on the pickling mechanism
cPickle
.
dumps
(
theano
.
compile
.
function_module
.
_pickle_Function
(
fn
)))
assert
b
(
f
)
==
b
(
f
)
# some sanity checks on the pickling mechanism
def
c
(
fn
):
return
len
(
cPickle
.
dumps
(
fn
))
assert
c
(
f
)
==
c
(
f
)
# some sanity checks on the pickling mechanism
assert
c
(
g
)
==
c
(
g
)
# some sanity checks on the pickling mechanism
assert
c
(
f
)
==
c
(
f
)
# some sanity checks on the pickling mechanism
assert
c
(
g
)
==
c
(
g
)
# some sanity checks on the pickling mechanism
# now run the function once to create temporaries within the no-gc
# linker
...
...
@@ -86,28 +90,32 @@ def test_gc_never_pickles_temporaries():
# allow_gc should leave the function un-changed by calling
assert
len_pre_f
==
len_post_f
#assert that g() didn't cause g to grow
#
because temporaries
that weren't collected shouldn't be pickled anyway
#assert that g() didn't cause g to grow
because temporaries
# that weren't collected shouldn't be pickled anyway
assert
len_post_f
==
len_post_g
,
(
f_linker
,
len_post_f
,
len_post_g
)
def
test_merge_opt_runtime
():
"""In the original merge optimization, the following graph took like caused the MERGE
optimizer to exhibit really bad performance (quadratic? exponential?)
"""In the original merge optimization, the following graph took
like caused the MERGE optimizer to exhibit really bad performance
(quadratic? exponential?)
Ironically, there is actually no merging to do in this graph.
"""
x
=
T
.
dvector
()
for
i
in
xrange
(
50
):
if
i
:
if
i
:
r
=
r
+
r
/
10
else
:
r
=
x
t
=
time
.
time
()
f
=
theano
.
function
([
x
],
r
,
mode
=
'FAST_COMPILE'
)
# FAST_RUN does in-place optimizer which requires a lot of toposorting, which is actually
# pretty slow at the moment. This test was designed to test MergeOptimizer... so I'm
# leaving toposort optimizations for a later date.
# FAST_RUN does in-place optimizer which requires a lot of
# toposorting, which is actually pretty slow at the moment. This
# test was designed to test MergeOptimizer... so I'm leaving
# toposort optimizations for a later date.
dt
=
time
.
time
()
-
t
assert
dt
<
5.0
#it should never take longer than 5 seconds to compile this graph
# it should never take longer than 5 seconds to compile this graph
assert
dt
<
5.0
theano/tensor/tests/test_opt.py
浏览文件 @
799e97dd
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论