Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7befad61
提交
7befad61
authored
8月 21, 2017
作者:
Frédéric Bastien
提交者:
GitHub
8月 21, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6323 from nouiz/tests
Fix test in the daily buildbot and make sure to don't loose the current linker.
上级
5cc70bc0
c69746ed
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
71 行增加
和
31 行删除
+71
-31
debugmode.py
theano/compile/debugmode.py
+0
-5
mode.py
theano/compile/mode.py
+3
-3
test_function_module.py
theano/compile/tests/test_function_module.py
+6
-2
configdefaults.py
theano/configdefaults.py
+15
-3
elemwise.py
theano/gpuarray/elemwise.py
+7
-4
opt.py
theano/gpuarray/opt.py
+2
-0
test_opt.py
theano/gpuarray/tests/test_opt.py
+22
-4
basic.py
theano/scalar/basic.py
+0
-0
basic_scipy.py
theano/scalar/basic_scipy.py
+6
-7
test_ctc.py
theano/tensor/nnet/tests/test_ctc.py
+4
-0
test_basic.py
theano/tensor/tests/test_basic.py
+6
-3
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
7befad61
...
@@ -10,7 +10,6 @@ import copy
...
@@ -10,7 +10,6 @@ import copy
import
sys
import
sys
import
gc
import
gc
import
logging
import
logging
import
six.moves.copyreg
as
copyreg
from
itertools
import
chain
,
product
as
itertools_product
from
itertools
import
chain
,
product
as
itertools_product
from
theano.compat
import
izip
from
theano.compat
import
izip
...
@@ -2414,10 +2413,6 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
...
@@ -2414,10 +2413,6 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
return
fn
return
fn
def
_pickle_DebugMode_Maker
(
maker
):
raise
NotImplementedError
(
'DebugMode is not picklable (yet)'
)
copyreg
.
pickle
(
_Maker
,
_pickle_DebugMode_Maker
)
########################
########################
#
#
# API symbol: DebugMode
# API symbol: DebugMode
...
...
theano/compile/mode.py
浏览文件 @
7befad61
...
@@ -317,7 +317,7 @@ class Mode(object):
...
@@ -317,7 +317,7 @@ class Mode(object):
self
.
provided_optimizer
)
self
.
provided_optimizer
)
# N.B. opt might be a Query instance, not sure what else it might be...
# N.B. opt might be a Query instance, not sure what else it might be...
# string? Optimizer? OptDB? who knows???
# string? Optimizer? OptDB? who knows???
return
self
.
clone
(
optimizer
=
opt
.
including
(
*
tags
))
return
self
.
clone
(
optimizer
=
opt
.
including
(
*
tags
)
,
linker
=
link
)
def
register
(
self
,
*
optimizations
):
def
register
(
self
,
*
optimizations
):
"""Adds new optimization instances to a mode.
"""Adds new optimization instances to a mode.
...
@@ -347,12 +347,12 @@ class Mode(object):
...
@@ -347,12 +347,12 @@ class Mode(object):
def
excluding
(
self
,
*
tags
):
def
excluding
(
self
,
*
tags
):
link
,
opt
=
self
.
get_linker_optimizer
(
self
.
provided_linker
,
link
,
opt
=
self
.
get_linker_optimizer
(
self
.
provided_linker
,
self
.
provided_optimizer
)
self
.
provided_optimizer
)
return
self
.
clone
(
optimizer
=
opt
.
excluding
(
*
tags
))
return
self
.
clone
(
optimizer
=
opt
.
excluding
(
*
tags
)
,
linker
=
link
)
def
requiring
(
self
,
*
tags
):
def
requiring
(
self
,
*
tags
):
link
,
opt
=
self
.
get_linker_optimizer
(
self
.
provided_linker
,
link
,
opt
=
self
.
get_linker_optimizer
(
self
.
provided_linker
,
self
.
provided_optimizer
)
self
.
provided_optimizer
)
return
self
.
clone
(
optimizer
=
opt
.
requiring
(
*
tags
))
return
self
.
clone
(
optimizer
=
opt
.
requiring
(
*
tags
)
,
linker
=
link
)
def
clone
(
self
,
link_kwargs
=
None
,
optimizer
=
""
,
**
kwargs
):
def
clone
(
self
,
link_kwargs
=
None
,
optimizer
=
""
,
**
kwargs
):
"""
"""
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
7befad61
...
@@ -654,9 +654,13 @@ class T_picklefunction(unittest.TestCase):
...
@@ -654,9 +654,13 @@ class T_picklefunction(unittest.TestCase):
def
test_output_keys
(
self
):
def
test_output_keys
(
self
):
x
=
T
.
vector
()
x
=
T
.
vector
()
f
=
theano
.
function
([
x
],
{
'vec'
:
x
**
2
})
f
=
theano
.
function
([
x
],
{
'vec'
:
x
**
2
})
assert
isinstance
(
f
([
2
,
3
,
4
]),
dict
)
o
=
f
([
2
,
3
,
4
])
assert
isinstance
(
o
,
dict
)
assert
np
.
allclose
(
o
[
'vec'
],
[
4
,
9
,
16
])
g
=
copy
.
deepcopy
(
f
)
g
=
copy
.
deepcopy
(
f
)
assert
isinstance
(
g
([
2
,
3
,
4
]),
dict
)
o
=
g
([
2
,
3
,
4
])
assert
isinstance
(
o
,
dict
)
assert
np
.
allclose
(
o
[
'vec'
],
[
4
,
9
,
16
])
def
test_deepcopy_shared_container
(
self
):
def
test_deepcopy_shared_container
(
self
):
# Ensure that shared containers remain shared after a deep copy.
# Ensure that shared containers remain shared after a deep copy.
...
...
theano/configdefaults.py
浏览文件 @
7befad61
...
@@ -466,12 +466,24 @@ AddConfigVar(
...
@@ -466,12 +466,24 @@ AddConfigVar(
# scalable.
# scalable.
# Also, please be careful not to modify the first item in the enum when adding
# Also, please be careful not to modify the first item in the enum when adding
# new modes, since it is the default mode.
# new modes, since it is the default mode.
def
filter_mode
(
val
):
if
val
in
[
'Mode'
,
'DebugMode'
,
'FAST_RUN'
,
'NanGuardMode'
,
'FAST_COMPILE'
,
'DEBUG_MODE'
]:
return
val
# This can be executed before Theano is completly imported, so
# theano.Mode is not always available.
elif
hasattr
(
theano
,
'Mode'
)
and
isinstance
(
val
,
theano
.
Mode
):
return
val
else
:
raise
ValueError
(
"Expected one of those string 'Mode', 'DebugMode',"
" 'FAST_RUN', 'NanGuardMode', 'FAST_COMPILE',"
" 'DEBUG_MODE' or an instance of Mode."
)
AddConfigVar
(
AddConfigVar
(
'mode'
,
'mode'
,
"Default compilation mode"
,
"Default compilation mode"
,
EnumStr
(
'Mode'
,
'DebugMode'
,
'FAST_RUN'
,
ConfigParam
(
'Mode'
,
filter_mode
),
'NanGuardMode'
,
'FAST_COMPILE'
,
'DEBUG_MODE'
),
in_c_key
=
False
)
in_c_key
=
False
)
param
=
"g++"
param
=
"g++"
...
...
theano/gpuarray/elemwise.py
浏览文件 @
7befad61
...
@@ -165,10 +165,13 @@ class GpuElemwise(HideC, Elemwise):
...
@@ -165,10 +165,13 @@ class GpuElemwise(HideC, Elemwise):
scal_v_out
=
fake_node
.
outputs
scal_v_out
=
fake_node
.
outputs
assert
len
(
scal_v_out
)
==
len
(
node
.
outputs
)
assert
len
(
scal_v_out
)
==
len
(
node
.
outputs
)
kop
=
fake_node
.
op
.
c_code
(
fake_node
,
'elem_scalar'
,
try
:
inps
,
outs
,
kop
=
fake_node
.
op
.
c_code
(
fake_node
,
'elem_scalar'
,
dict
(
fail
=
'return;'
))
inps
,
outs
,
dict
(
fail
=
'return;'
))
except
MethodNotDefined
:
raise
AssertionError
(
"No c code for this scalar. Can not make a GpuElemwise"
)
# If the following assert fail, then we need to update the
# If the following assert fail, then we need to update the
# code handler above.
# code handler above.
assert
'npy_float16'
not
in
kop
assert
'npy_float16'
not
in
kop
...
...
theano/gpuarray/opt.py
浏览文件 @
7befad61
...
@@ -748,6 +748,8 @@ def local_gpua_elemwise(op, context_name, inputs, outputs):
...
@@ -748,6 +748,8 @@ def local_gpua_elemwise(op, context_name, inputs, outputs):
scal_op
)
scal_op
)
if
not
have_cuda
:
if
not
have_cuda
:
return
None
return
None
if
not
scal_op
.
supports_c_code
(
inputs
,
outputs
):
return
res
=
GpuElemwise
(
scal_op
,
name
=
name
,
res
=
GpuElemwise
(
scal_op
,
name
=
name
,
inplace_pattern
=
copy
.
copy
(
op
.
inplace_pattern
),
inplace_pattern
=
copy
.
copy
(
op
.
inplace_pattern
),
nfunc_spec
=
op
.
nfunc_spec
)
nfunc_spec
=
op
.
nfunc_spec
)
...
...
theano/gpuarray/tests/test_opt.py
浏览文件 @
7befad61
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
numpy
as
np
from
nose.tools
import
assert_raises
from
nose.tools
import
assert_raises
import
numpy
as
np
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
...
@@ -745,7 +745,11 @@ class Conv_opt_test(unittest.TestCase):
...
@@ -745,7 +745,11 @@ class Conv_opt_test(unittest.TestCase):
mode
=
mode_with_gpu
.
including
(
'conv_meta'
)
mode
=
mode_with_gpu
.
including
(
'conv_meta'
)
ref_func
=
theano
.
function
([],
conv_op
,
mode
=
mode_with_gpu
)
ref_func
=
theano
.
function
([],
conv_op
,
mode
=
mode_with_gpu
)
conv_func
=
theano
.
function
([],
conv_op
,
mode
=
mode
)
# All meta optimizer compile a new function. This need to know
# the current linker, but this information is not available,
# so it use the default mode.
with
theano
.
change_flags
(
mode
=
mode
):
conv_func
=
theano
.
function
([],
conv_op
,
mode
=
mode
)
assert
any
([
isinstance
(
node
.
op
,
op
)
assert
any
([
isinstance
(
node
.
op
,
op
)
for
node
in
conv_func
.
maker
.
fgraph
.
toposort
()])
for
node
in
conv_func
.
maker
.
fgraph
.
toposort
()])
utt
.
assert_allclose
(
conv_func
(),
ref_func
())
utt
.
assert_allclose
(
conv_func
(),
ref_func
())
...
@@ -787,13 +791,20 @@ class Conv_opt_test(unittest.TestCase):
...
@@ -787,13 +791,20 @@ class Conv_opt_test(unittest.TestCase):
mode
=
mode_with_gpu
.
including
(
'conv_meta'
)
mode
=
mode_with_gpu
.
including
(
'conv_meta'
)
ref_func
=
theano
.
function
([],
conv_op
,
mode
=
mode_with_gpu
)
ref_func
=
theano
.
function
([],
conv_op
,
mode
=
mode_with_gpu
)
conv_func
=
theano
.
function
([],
conv_op
,
mode
=
mode
)
# All meta optimizer compile a new function. This need to know
# the current linker, but this information is not available,
# so it use the default mode.
with
theano
.
change_flags
(
mode
=
mode
):
conv_func
=
theano
.
function
([],
conv_op
,
mode
=
mode
)
if
op
is
not
None
:
if
op
is
not
None
:
assert
any
([
isinstance
(
node
.
op
,
op
)
assert
any
([
isinstance
(
node
.
op
,
op
)
for
node
in
conv_func
.
maker
.
fgraph
.
toposort
()])
for
node
in
conv_func
.
maker
.
fgraph
.
toposort
()])
utt
.
assert_allclose
(
conv_func
(),
ref_func
())
utt
.
assert_allclose
(
conv_func
(),
ref_func
())
def
test_optimizers
(
self
):
def
test_optimizers_2d
(
self
):
if
theano
.
config
.
cxx
==
""
:
raise
SkipTest
(
"Need a c compiler."
)
imshp2d
=
[(
2
,
3
,
5
,
5
),
(
2
,
2
,
5
,
7
),
(
2
,
1
,
3
,
3
)]
imshp2d
=
[(
2
,
3
,
5
,
5
),
(
2
,
2
,
5
,
7
),
(
2
,
1
,
3
,
3
)]
kshp2d
=
[(
4
,
3
,
3
,
3
),
(
3
,
2
,
3
,
5
),
(
4
,
1
,
1
,
1
)]
kshp2d
=
[(
4
,
3
,
3
,
3
),
(
3
,
2
,
3
,
5
),
(
4
,
1
,
1
,
1
)]
tshp2d
=
[(
2
,
4
,
3
,
3
),
(
2
,
3
,
3
,
3
),
(
2
,
4
,
3
,
3
)]
tshp2d
=
[(
2
,
4
,
3
,
3
),
(
2
,
3
,
3
,
3
),
(
2
,
4
,
3
,
3
)]
...
@@ -827,6 +838,10 @@ class Conv_opt_test(unittest.TestCase):
...
@@ -827,6 +838,10 @@ class Conv_opt_test(unittest.TestCase):
'conv_gemm:default'
,
'conv_gemm:default'
,
dnn
.
GpuDnnConv
)
dnn
.
GpuDnnConv
)
def
test_optimizers_3d
(
self
):
if
theano
.
config
.
cxx
==
""
:
raise
SkipTest
(
"Need a c compiler."
)
imshp3d
=
[(
2
,
3
,
5
,
5
,
5
),
(
2
,
2
,
5
,
7
,
5
),
(
2
,
1
,
3
,
3
,
3
)]
imshp3d
=
[(
2
,
3
,
5
,
5
,
5
),
(
2
,
2
,
5
,
7
,
5
),
(
2
,
1
,
3
,
3
,
3
)]
kshp3d
=
[(
4
,
3
,
3
,
3
,
3
),
(
3
,
2
,
3
,
5
,
3
),
(
4
,
1
,
1
,
1
,
1
)]
kshp3d
=
[(
4
,
3
,
3
,
3
,
3
),
(
3
,
2
,
3
,
5
,
3
),
(
4
,
1
,
1
,
1
,
1
)]
tshp3d
=
[(
2
,
4
,
3
,
3
,
3
),
(
2
,
3
,
3
,
3
,
3
),
(
2
,
4
,
3
,
3
,
3
)]
tshp3d
=
[(
2
,
4
,
3
,
3
,
3
),
(
2
,
3
,
3
,
3
,
3
),
(
2
,
4
,
3
,
3
,
3
)]
...
@@ -865,6 +880,9 @@ class Conv_opt_test(unittest.TestCase):
...
@@ -865,6 +880,9 @@ class Conv_opt_test(unittest.TestCase):
'conv_gemm:default'
,
'conv_gemm:default'
,
dnn
.
GpuDnnConv
)
dnn
.
GpuDnnConv
)
def
test_optimizers_non_default
(
self
):
if
theano
.
config
.
cxx
==
""
:
raise
SkipTest
(
"Need a c compiler."
)
# conv2d forward pass with Non-default border_mode and filter_dilation
# conv2d forward pass with Non-default border_mode and filter_dilation
imshp2d
=
[(
2
,
3
,
5
,
5
),
(
4
,
2
,
5
,
5
)]
imshp2d
=
[(
2
,
3
,
5
,
5
),
(
4
,
2
,
5
,
5
)]
kshp2d
=
[(
4
,
3
,
3
,
3
),
(
3
,
2
,
3
,
3
)]
kshp2d
=
[(
4
,
3
,
3
,
3
),
(
3
,
2
,
3
,
3
)]
...
...
theano/scalar/basic.py
浏览文件 @
7befad61
差异被折叠。
点击展开。
theano/scalar/basic_scipy.py
浏览文件 @
7befad61
...
@@ -52,7 +52,8 @@ class Erf(UnaryScalarOp):
...
@@ -52,7 +52,8 @@ class Erf(UnaryScalarOp):
z
,
=
out
z
,
=
out
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
raise
NotImplementedError
(
'type not supported'
,
type
)
raise
NotImplementedError
(
'type not supported'
,
type
)
return
"
%(z)
s = erf(
%(x)
s);"
%
locals
()
cast
=
node
.
outputs
[
0
]
.
type
.
dtype_specs
()[
1
]
return
"
%(z)
s = erf((
%(cast)
s)
%(x)
s);"
%
locals
()
erf
=
Erf
(
upgrade_to_float
,
name
=
'erf'
)
erf
=
Erf
(
upgrade_to_float
,
name
=
'erf'
)
...
@@ -83,7 +84,8 @@ class Erfc(UnaryScalarOp):
...
@@ -83,7 +84,8 @@ class Erfc(UnaryScalarOp):
z
,
=
out
z
,
=
out
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
if
node
.
inputs
[
0
]
.
type
in
complex_types
:
raise
NotImplementedError
(
'type not supported'
,
type
)
raise
NotImplementedError
(
'type not supported'
,
type
)
return
"
%(z)
s = erfc(
%(x)
s);"
%
locals
()
cast
=
node
.
outputs
[
0
]
.
type
.
dtype_specs
()[
1
]
return
"
%(z)
s = erfc((
%(cast)
s)
%(x)
s);"
%
locals
()
# scipy.special.erfc don't support complex. Why?
# scipy.special.erfc don't support complex. Why?
erfc
=
Erfc
(
upgrade_to_float_no_complex
,
name
=
'erfc'
)
erfc
=
Erfc
(
upgrade_to_float_no_complex
,
name
=
'erfc'
)
...
@@ -275,11 +277,8 @@ class GammaLn(UnaryScalarOp):
...
@@ -275,11 +277,8 @@ class GammaLn(UnaryScalarOp):
# For some reason, on the GPU, uint64 inputs don't get casted
# For some reason, on the GPU, uint64 inputs don't get casted
# automatically to float64. This make the compilation crash
# automatically to float64. This make the compilation crash
dtype
=
""
dtype
=
""
if
node
.
outputs
[
0
]
.
dtype
==
'float64'
:
cast
=
node
.
outputs
[
0
]
.
type
.
dtype_specs
()[
1
]
dtype
=
"(double)"
return
"""
%(z)
s = lgamma((
%(cast)
s)
%(x)
s);"""
%
locals
()
elif
node
.
outputs
[
0
]
.
dtype
==
'float32'
:
dtype
=
"(float)"
return
"""
%(z)
s = lgamma(
%(dtype)
s
%(x)
s);"""
%
locals
()
gammaln
=
GammaLn
(
upgrade_to_float
,
name
=
'gammaln'
)
gammaln
=
GammaLn
(
upgrade_to_float
,
name
=
'gammaln'
)
...
...
theano/tensor/nnet/tests/test_ctc.py
浏览文件 @
7befad61
from
__future__
import
(
division
,
absolute_import
,
print_function
)
from
__future__
import
(
division
,
absolute_import
,
print_function
)
import
unittest
import
unittest
from
nose.plugins.skip
import
SkipTest
import
numpy
as
np
import
numpy
as
np
import
theano
import
theano
...
@@ -84,6 +85,9 @@ class TestCTC(unittest.TestCase):
...
@@ -84,6 +85,9 @@ class TestCTC(unittest.TestCase):
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
if
theano
.
config
.
mode
==
"FAST_COMPILE"
or
theano
.
config
.
cxx
==
""
:
raise
SkipTest
(
"We need a c compiler"
)
if
not
ctc_available
():
if
not
ctc_available
():
self
.
skipTest
(
'Optional library warp-ctc not available'
)
self
.
skipTest
(
'Optional library warp-ctc not available'
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
7befad61
...
@@ -1242,7 +1242,8 @@ CeilTester = makeBroadcastTester(
...
@@ -1242,7 +1242,8 @@ CeilTester = makeBroadcastTester(
CeilInplaceTester
=
makeBroadcastTester
(
CeilInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
ceil_inplace
,
op
=
inplace
.
ceil_inplace
,
expected
=
upcast_float16_ufunc
(
np
.
ceil
),
expected
=
upcast_float16_ufunc
(
np
.
ceil
),
good
=
_good_broadcast_unary_normal_no_complex
,
good
=
copymod
(
_good_broadcast_unary_normal_no_complex
,
without
=
[
'integers'
,
'int8'
,
'uint8'
,
'uint16'
]),
# corner cases includes a lot of integers: points where Ceil is not
# corner cases includes a lot of integers: points where Ceil is not
# continuous (not differentiable)
# continuous (not differentiable)
inplace
=
True
)
inplace
=
True
)
...
@@ -1256,7 +1257,8 @@ FloorTester = makeBroadcastTester(
...
@@ -1256,7 +1257,8 @@ FloorTester = makeBroadcastTester(
FloorInplaceTester
=
makeBroadcastTester
(
FloorInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
floor_inplace
,
op
=
inplace
.
floor_inplace
,
expected
=
upcast_float16_ufunc
(
np
.
floor
),
expected
=
upcast_float16_ufunc
(
np
.
floor
),
good
=
_good_broadcast_unary_normal_no_complex
,
good
=
copymod
(
_good_broadcast_unary_normal_no_complex
,
without
=
[
"integers"
,
"int8"
,
"uint8"
,
"uint16"
]),
inplace
=
True
)
inplace
=
True
)
TruncInplaceTester
=
makeBroadcastTester
(
TruncInplaceTester
=
makeBroadcastTester
(
...
@@ -1603,7 +1605,8 @@ Arctan2InplaceTester = makeBroadcastTester(
...
@@ -1603,7 +1605,8 @@ Arctan2InplaceTester = makeBroadcastTester(
op
=
inplace
.
arctan2_inplace
,
op
=
inplace
.
arctan2_inplace
,
expected
=
np
.
arctan2
,
expected
=
np
.
arctan2
,
good
=
copymod
(
_good_broadcast_binary_arctan2
,
good
=
copymod
(
_good_broadcast_binary_arctan2
,
without
=
[
'integers'
,
'int8'
,
'uint8'
,
'uint16'
]),
without
=
[
'integers'
,
'int8'
,
'uint8'
,
'uint16'
,
'dtype_mixup_2'
]),
inplace
=
True
)
inplace
=
True
)
CoshTester
=
makeBroadcastTester
(
CoshTester
=
makeBroadcastTester
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论