Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
00b55dc2
提交
00b55dc2
authored
4月 04, 2017
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix test errors.
上级
213e07c8
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
31 行增加
和
26 行删除
+31
-26
test_others.py
theano/gpuarray/tests/test_others.py
+5
-3
test_type.py
theano/gpuarray/tests/test_type.py
+4
-4
pkl_utils.py
theano/misc/pkl_utils.py
+14
-8
scan_opt.py
theano/scan_module/scan_opt.py
+1
-1
test_scan.py
theano/scan_module/tests/test_scan.py
+0
-2
test_opt.py
theano/tensor/tests/test_opt.py
+7
-8
没有找到文件。
theano/gpuarray/tests/test_others.py
浏览文件 @
00b55dc2
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
from
.config
import
test_ctx_name
,
mode_with_gpu
from
.config
import
test_ctx_name
,
mode_with_gpu
from
..basic_ops
import
(
HostFromGpu
,
GpuFromHost
)
from
..type
import
(
get_context
,
GpuArrayType
,
GpuArraySharedVariable
,
from
..type
import
(
get_context
,
GpuArrayType
,
GpuArraySharedVariable
,
gpuarray_shared_constructor
)
gpuarray_shared_constructor
)
...
@@ -10,12 +11,13 @@ import numpy as np
...
@@ -10,12 +11,13 @@ import numpy as np
from
theano.misc.tests.test_may_share_memory
import
may_share_memory_core
from
theano.misc.tests.test_may_share_memory
import
may_share_memory_core
from
theano.misc.pkl_utils
import
dump
,
load
from
theano.misc.pkl_utils
import
dump
,
load
from
theano.tensor.tests.test_opt
import
test_fusion
as
t_fusion
from
theano.tensor.tests
import
test_opt
class
test_fusion
(
t_fusion
):
class
test_fusion
(
t
est_opt
.
test
_fusion
):
mode
=
mode_with_gpu
mode
=
mode_with_gpu
shared
=
gpuarray_shared_constructor
_shared
=
staticmethod
(
gpuarray_shared_constructor
)
topo_exclude
=
(
GpuFromHost
,
HostFromGpu
)
def
test_may_share_memory
():
def
test_may_share_memory
():
...
...
theano/gpuarray/tests/test_type.py
浏览文件 @
00b55dc2
...
@@ -94,8 +94,8 @@ test_shared_options = makeSharedTester(
...
@@ -94,8 +94,8 @@ test_shared_options = makeSharedTester(
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
pygpu
.
gpuarray
.
GpuArray
),
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
pygpu
.
gpuarray
.
GpuArray
),
theano_fct_
=
theano
.
tensor
.
exp
,
theano_fct_
=
theano
.
tensor
.
exp
,
ref_fct_
=
np
.
exp
,
ref_fct_
=
np
.
exp
,
cast_value_
=
lambda
v
:
pygpu
.
a
sa
rray
(
v
,
context
=
get_context
(
test_ctx_name
),
cast_value_
=
lambda
v
:
pygpu
.
array
(
v
,
context
=
get_context
(
test_ctx_name
),
cls
=
pygpu
.
_array
.
ndgpuarray
),
cls
=
pygpu
.
_array
.
ndgpuarray
),
name
=
'test_shared_options'
)
name
=
'test_shared_options'
)
...
@@ -113,6 +113,6 @@ test_shared_options2 = makeSharedTester(
...
@@ -113,6 +113,6 @@ test_shared_options2 = makeSharedTester(
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
pygpu
.
gpuarray
.
GpuArray
),
test_internal_type_
=
lambda
a
:
isinstance
(
a
,
pygpu
.
gpuarray
.
GpuArray
),
theano_fct_
=
theano
.
tensor
.
exp
,
theano_fct_
=
theano
.
tensor
.
exp
,
ref_fct_
=
np
.
exp
,
ref_fct_
=
np
.
exp
,
cast_value_
=
lambda
v
:
pygpu
.
a
sa
rray
(
v
,
context
=
get_context
(
test_ctx_name
),
cast_value_
=
lambda
v
:
pygpu
.
array
(
v
,
context
=
get_context
(
test_ctx_name
),
cls
=
pygpu
.
_array
.
ndgpuarray
),
cls
=
pygpu
.
_array
.
ndgpuarray
),
name
=
'test_shared_options2'
)
name
=
'test_shared_options2'
)
theano/misc/pkl_utils.py
浏览文件 @
00b55dc2
...
@@ -27,11 +27,6 @@ from theano.compat import PY3
...
@@ -27,11 +27,6 @@ from theano.compat import PY3
from
six
import
string_types
from
six
import
string_types
from
theano.compile.sharedvalue
import
SharedVariable
from
theano.compile.sharedvalue
import
SharedVariable
try
:
import
pygpu
except
ImportError
:
pygpu
=
None
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
__authors__
=
"Pascal Lamblin"
__authors__
=
"Pascal Lamblin"
__copyright__
=
"Copyright 2013, Universite de Montreal"
__copyright__
=
"Copyright 2013, Universite de Montreal"
...
@@ -204,10 +199,17 @@ class PersistentNdarrayID(object):
...
@@ -204,10 +199,17 @@ class PersistentNdarrayID(object):
class
PersistentGpuArrayID
(
PersistentNdarrayID
):
class
PersistentGpuArrayID
(
PersistentNdarrayID
):
def
__call__
(
self
,
obj
):
def
__call__
(
self
,
obj
):
from
theano.gpuarray.type
import
_name_for_ctx
try
:
import
pygpu
except
ImportError
:
pygpu
=
None
if
(
pygpu
and
if
(
pygpu
and
isinstance
(
obj
,
pygpu
.
gpuarray
.
GpuArray
)):
isinstance
(
obj
,
pygpu
.
gpuarray
.
GpuArray
)):
if
id
(
obj
)
not
in
self
.
seen
:
if
id
(
obj
)
not
in
self
.
seen
:
def
write_array
(
f
):
def
write_array
(
f
):
pickle
.
dump
(
f
,
_name_for_ctx
(
obj
.
context
),
2
)
np
.
lib
.
format
.
write_array
(
f
,
np
.
asarray
(
obj
))
np
.
lib
.
format
.
write_array
(
f
,
np
.
asarray
(
obj
))
name
=
self
.
_resolve_name
(
obj
)
name
=
self
.
_resolve_name
(
obj
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
zipadd
(
write_array
,
self
.
zip_file
,
name
)
...
@@ -282,24 +284,28 @@ class PersistentNdarrayLoad(object):
...
@@ -282,24 +284,28 @@ class PersistentNdarrayLoad(object):
self
.
cache
=
{}
self
.
cache
=
{}
def
__call__
(
self
,
persid
):
def
__call__
(
self
,
persid
):
from
theano.gpuarray.type
import
get_context
array_type
,
name
=
persid
.
split
(
'.'
)
array_type
,
name
=
persid
.
split
(
'.'
)
if
name
in
self
.
cache
:
if
name
in
self
.
cache
:
return
self
.
cache
[
name
]
return
self
.
cache
[
name
]
ret
=
None
ret
=
None
array
=
np
.
lib
.
format
.
read_array
(
self
.
zip_file
.
open
(
name
))
if
array_type
==
'gpuarray'
:
if
array_type
==
'gpuarray'
:
with
self
.
zip_file
.
open
(
name
)
as
f
:
ctx_name
=
pickle
.
load
(
f
)
array
=
np
.
lib
.
format
.
read_array
(
f
)
if
config
.
experimental
.
unpickle_gpu_on_cpu
:
if
config
.
experimental
.
unpickle_gpu_on_cpu
:
# directly return numpy array
# directly return numpy array
warnings
.
warn
(
"config.experimental.unpickle_gpu_on_cpu is set "
warnings
.
warn
(
"config.experimental.unpickle_gpu_on_cpu is set "
"to True. Unpickling GpuArray as numpy.ndarray"
)
"to True. Unpickling GpuArray as numpy.ndarray"
)
ret
=
array
ret
=
array
elif
pygpu
:
elif
pygpu
:
ret
=
pygpu
.
array
(
array
)
ret
=
pygpu
.
array
(
array
,
context
=
get_context
(
ctx_name
)
)
else
:
else
:
raise
ImportError
(
"pygpu not found. Cannot unpickle GpuArray"
)
raise
ImportError
(
"pygpu not found. Cannot unpickle GpuArray"
)
else
:
else
:
ret
=
array
with
self
.
zip_file
.
open
(
name
)
as
f
:
ret
=
np
.
lib
.
format
.
read_array
(
f
)
self
.
cache
[
name
]
=
ret
self
.
cache
[
name
]
=
ret
return
ret
return
ret
...
...
theano/scan_module/scan_opt.py
浏览文件 @
00b55dc2
...
@@ -1651,7 +1651,7 @@ class ScanMerge(gof.Optimizer):
...
@@ -1651,7 +1651,7 @@ class ScanMerge(gof.Optimizer):
info
[
'truncate_gradient'
]
=
nodes
[
0
]
.
op
.
truncate_gradient
info
[
'truncate_gradient'
]
=
nodes
[
0
]
.
op
.
truncate_gradient
info
[
'name'
]
=
'&'
.
join
([
nd
.
op
.
name
for
nd
in
nodes
])
info
[
'name'
]
=
'&'
.
join
([
nd
.
op
.
name
for
nd
in
nodes
])
info
[
'mode'
]
=
nodes
[
0
]
.
op
.
mode
info
[
'mode'
]
=
nodes
[
0
]
.
op
.
mode
info
[
'gpu'
]
=
False
info
[
'gpu
a
'
]
=
False
info
[
'as_while'
]
=
as_while
info
[
'as_while'
]
=
as_while
info
[
'profile'
]
=
nodes
[
0
]
.
op
.
profile
info
[
'profile'
]
=
nodes
[
0
]
.
op
.
profile
info
[
'allow_gc'
]
=
nodes
[
0
]
.
op
.
allow_gc
info
[
'allow_gc'
]
=
nodes
[
0
]
.
op
.
allow_gc
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
00b55dc2
...
@@ -44,12 +44,10 @@ if theano.config.mode == 'FAST_COMPILE':
...
@@ -44,12 +44,10 @@ if theano.config.mode == 'FAST_COMPILE':
mode_with_opt
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
mode_with_opt
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
else
:
mode_with_opt
=
theano
.
compile
.
mode
.
get_default_mode
()
mode_with_opt
=
theano
.
compile
.
mode
.
get_default_mode
()
mode_with_gpu
=
mode_with_opt
.
including
(
'gpu'
,
'scan'
)
if
theano
.
config
.
mode
in
(
'DEBUG_MODE'
,
'DebugMode'
):
if
theano
.
config
.
mode
in
(
'DEBUG_MODE'
,
'DebugMode'
):
mode_nodebug
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
mode_nodebug
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
else
:
else
:
mode_nodebug
=
mode_with_opt
mode_nodebug
=
mode_with_opt
mode_with_gpu_nodebug
=
mode_nodebug
.
including
(
'gpu'
,
'scan'
)
type_eps
=
{
'float64'
:
1e-7
,
type_eps
=
{
'float64'
:
1e-7
,
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
00b55dc2
...
@@ -908,7 +908,8 @@ def test_const_type_in_mul_canonizer():
...
@@ -908,7 +908,8 @@ def test_const_type_in_mul_canonizer():
class
test_fusion
(
unittest
.
TestCase
):
class
test_fusion
(
unittest
.
TestCase
):
mode
=
copy
.
copy
(
compile
.
mode
.
get_default_mode
())
mode
=
copy
.
copy
(
compile
.
mode
.
get_default_mode
())
_shared
=
shared
_shared
=
staticmethod
(
shared
)
topo_exclude
=
()
def
do
(
self
,
mode
,
shared_fn
,
shp
,
nb_repeat
=
1
,
assert_len_topo
=
True
,
slice
=
None
):
def
do
(
self
,
mode
,
shared_fn
,
shp
,
nb_repeat
=
1
,
assert_len_topo
=
True
,
slice
=
None
):
"""
"""
...
@@ -1121,10 +1122,6 @@ class test_fusion(unittest.TestCase):
...
@@ -1121,10 +1122,6 @@ class test_fusion(unittest.TestCase):
t1
=
time
.
time
()
t1
=
time
.
time
()
out
=
out
.
get_value
()
out
=
out
.
get_value
()
# print "CASE2/3", f.maker.fgraph.toposort()
# print 'CASE2/3', f.maker.fgraph
# print 'CASE2/3', f.maker.fgraph.toposort()[3].op.scalar_op.fgraph
times
[
id
]
=
t1
-
t0
times
[
id
]
=
t1
-
t0
atol
=
1e-8
atol
=
1e-8
if
out_dtype
==
'float32'
:
if
out_dtype
==
'float32'
:
...
@@ -1135,7 +1132,8 @@ class test_fusion(unittest.TestCase):
...
@@ -1135,7 +1132,8 @@ class test_fusion(unittest.TestCase):
print
(
out
)
print
(
out
)
print
(
answer
*
nb_repeat
)
print
(
answer
*
nb_repeat
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo_
=
topo
topo_
=
[
n
for
n
in
topo
if
not
isinstance
(
n
.
op
,
self
.
topo_exclude
)]
if
assert_len_topo
:
if
assert_len_topo
:
if
not
len
(
topo_
)
==
nb_elemwise
:
if
not
len
(
topo_
)
==
nb_elemwise
:
fail3
.
append
((
id
,
topo_
,
nb_elemwise
))
fail3
.
append
((
id
,
topo_
,
nb_elemwise
))
...
@@ -1274,9 +1272,10 @@ class test_fusion(unittest.TestCase):
...
@@ -1274,9 +1272,10 @@ class test_fusion(unittest.TestCase):
x
,
y
,
z
=
dmatrices
(
'xyz'
)
x
,
y
,
z
=
dmatrices
(
'xyz'
)
f
=
theano
.
function
([
x
,
y
,
z
],
tensor
.
dot
(
x
,
y
)
+
x
+
y
+
z
,
mode
=
mode
)
f
=
theano
.
function
([
x
,
y
,
z
],
tensor
.
dot
(
x
,
y
)
+
x
+
y
+
z
,
mode
=
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
[
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
not
isinstance
(
n
.
op
,
self
.
topo_exclude
)]
assert
len
(
topo
)
==
2
assert
len
(
topo
)
==
2
assert
f
.
maker
.
fgraph
.
toposort
()
[
-
1
]
.
op
.
inplace_pattern
assert
topo
[
-
1
]
.
op
.
inplace_pattern
f
(
np
.
random
.
random
((
5
,
5
)),
np
.
random
.
random
((
5
,
5
)),
f
(
np
.
random
.
random
((
5
,
5
)),
np
.
random
.
random
((
5
,
5
)),
np
.
random
.
random
((
5
,
5
)))
np
.
random
.
random
((
5
,
5
)))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论