Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
aa37b4bb
提交
aa37b4bb
authored
10月 22, 2014
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2208 from nouiz/tests
Crash fix and Tests fix
上级
918c51cb
dfb260cc
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
42 行增加
和
21 行删除
+42
-21
lazylinker_c.c
theano/gof/lazylinker_c.c
+1
-1
lazylinker_c.py
theano/gof/lazylinker_c.py
+3
-1
test_vm.py
theano/gof/tests/test_vm.py
+19
-14
opt.py
theano/sandbox/cuda/opt.py
+9
-3
test_conv_cuda_ndarray.py
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
+5
-1
test_mlp.py
theano/sandbox/cuda/tests/test_mlp.py
+5
-1
没有找到文件。
theano/gof/lazylinker_c.c
浏览文件 @
aa37b4bb
...
@@ -1024,7 +1024,7 @@ static PyTypeObject lazylinker_ext_CLazyLinkerType = {
...
@@ -1024,7 +1024,7 @@ static PyTypeObject lazylinker_ext_CLazyLinkerType = {
static
PyObject
*
get_version
(
PyObject
*
dummy
,
PyObject
*
args
)
static
PyObject
*
get_version
(
PyObject
*
dummy
,
PyObject
*
args
)
{
{
PyObject
*
result
=
PyFloat_FromDouble
(
0
.
2
0
);
PyObject
*
result
=
PyFloat_FromDouble
(
0
.
2
1
);
return
result
;
return
result
;
}
}
...
...
theano/gof/lazylinker_c.py
浏览文件 @
aa37b4bb
...
@@ -14,7 +14,8 @@ from theano.gof import cmodule
...
@@ -14,7 +14,8 @@ from theano.gof import cmodule
_logger
=
logging
.
getLogger
(
'theano.gof.lazylinker_c'
)
_logger
=
logging
.
getLogger
(
'theano.gof.lazylinker_c'
)
force_compile
=
False
force_compile
=
False
version
=
0.20
# must match constant returned in function get_version()
version
=
0.21
# must match constant returned in function get_version()
def
try_import
():
def
try_import
():
global
lazylinker_ext
global
lazylinker_ext
...
@@ -22,6 +23,7 @@ def try_import():
...
@@ -22,6 +23,7 @@ def try_import():
import
lazylinker_ext
import
lazylinker_ext
del
sys
.
path
[
0
]
del
sys
.
path
[
0
]
def
try_reload
():
def
try_reload
():
sys
.
path
[
0
:
0
]
=
[
config
.
compiledir
]
sys
.
path
[
0
:
0
]
=
[
config
.
compiledir
]
reload
(
lazylinker_ext
)
reload
(
lazylinker_ext
)
...
...
theano/gof/tests/test_vm.py
浏览文件 @
aa37b4bb
...
@@ -20,6 +20,7 @@ from theano import tensor
...
@@ -20,6 +20,7 @@ from theano import tensor
from
theano.ifelse
import
ifelse
from
theano.ifelse
import
ifelse
import
theano
import
theano
class
TestCallbacks
(
unittest
.
TestCase
):
class
TestCallbacks
(
unittest
.
TestCase
):
"""
"""
Test the VM_Linker's callback argument, which can be useful for debugging.
Test the VM_Linker's callback argument, which can be useful for debugging.
...
@@ -34,7 +35,7 @@ class TestCallbacks(unittest.TestCase):
...
@@ -34,7 +35,7 @@ class TestCallbacks(unittest.TestCase):
def
test_callback
(
self
):
def
test_callback
(
self
):
a
,
b
,
c
=
tensor
.
scalars
(
'abc'
)
a
,
b
,
c
=
tensor
.
scalars
(
'abc'
)
f
=
function
([
a
,
b
,
c
],
(
a
+
b
)
+
c
,
f
=
function
([
a
,
b
,
c
],
(
a
+
b
)
+
c
,
mode
=
Mode
(
mode
=
Mode
(
optimizer
=
None
,
optimizer
=
None
,
linker
=
vm
.
VM_Linker
(
callback
=
self
.
callback
)))
linker
=
vm
.
VM_Linker
(
callback
=
self
.
callback
)))
...
@@ -44,10 +45,9 @@ class TestCallbacks(unittest.TestCase):
...
@@ -44,10 +45,9 @@ class TestCallbacks(unittest.TestCase):
f
(
1
,
2
,
3
)
f
(
1
,
2
,
3
)
assert
sum
(
self
.
n_callbacks
.
values
())
==
len
(
f
.
maker
.
fgraph
.
toposort
())
*
2
assert
sum
(
self
.
n_callbacks
.
values
())
==
len
(
f
.
maker
.
fgraph
.
toposort
())
*
2
def
test_callback_with_ifelse
(
self
):
def
test_callback_with_ifelse
(
self
):
a
,
b
,
c
=
tensor
.
scalars
(
'abc'
)
a
,
b
,
c
=
tensor
.
scalars
(
'abc'
)
f
=
function
([
a
,
b
,
c
],
ifelse
(
a
,
2
*
b
,
2
*
c
),
f
=
function
([
a
,
b
,
c
],
ifelse
(
a
,
2
*
b
,
2
*
c
),
mode
=
Mode
(
mode
=
Mode
(
optimizer
=
None
,
optimizer
=
None
,
linker
=
vm
.
VM_Linker
(
callback
=
self
.
callback
)))
linker
=
vm
.
VM_Linker
(
callback
=
self
.
callback
)))
...
@@ -71,6 +71,7 @@ def test_speed():
...
@@ -71,6 +71,7 @@ def test_speed():
for
d
in
xrange
(
depth
):
for
d
in
xrange
(
depth
):
z
=
(
z
+
z
)
z
=
(
z
+
z
)
return
z
return
z
def
time_numpy
():
def
time_numpy
():
steps_a
=
5
steps_a
=
5
steps_b
=
100
steps_b
=
100
...
@@ -78,10 +79,10 @@ def test_speed():
...
@@ -78,10 +79,10 @@ def test_speed():
numpy_version
(
x
,
steps_a
)
numpy_version
(
x
,
steps_a
)
t0
=
time
.
time
()
t0
=
time
.
time
()
#print numpy_version(x, steps_a)
#
print numpy_version(x, steps_a)
t1
=
time
.
time
()
t1
=
time
.
time
()
t2
=
time
.
time
()
t2
=
time
.
time
()
#print numpy_version(x, steps_b)
#
print numpy_version(x, steps_b)
t3
=
time
.
time
()
t3
=
time
.
time
()
t_a
=
t1
-
t0
t_a
=
t1
-
t0
t_b
=
t3
-
t2
t_b
=
t3
-
t2
...
@@ -94,9 +95,8 @@ def test_speed():
...
@@ -94,9 +95,8 @@ def test_speed():
steps_a
=
5
steps_a
=
5
steps_b
=
100
steps_b
=
100
x
=
tensor
.
vector
()
x
=
tensor
.
vector
()
a
=
build_graph
(
x
,
steps_a
)
a
=
build_graph
(
x
,
steps_a
)
b
=
build_graph
(
x
,
steps_b
)
b
=
build_graph
(
x
,
steps_b
)
f_a
=
function
([
x
],
a
,
f_a
=
function
([
x
],
a
,
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
()),
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
()),
...
@@ -127,12 +127,13 @@ def test_speed():
...
@@ -127,12 +127,13 @@ def test_speed():
time_linker
(
'c|py'
,
OpWiseCLinker
)
time_linker
(
'c|py'
,
OpWiseCLinker
)
time_linker
(
'vmLinker'
,
vm
.
VM_Linker
)
time_linker
(
'vmLinker'
,
vm
.
VM_Linker
)
time_linker
(
'vmLinker_nogc'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
time_linker
(
'vmLinker_nogc'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
if
theano
.
config
.
cxx
:
if
theano
.
config
.
cxx
:
time_linker
(
'vmLinker_CLOOP'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
,
time_linker
(
'vmLinker_CLOOP'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
,
use_cloop
=
True
))
use_cloop
=
True
))
time_numpy
()
time_numpy
()
def
test_speed_lazy
():
def
test_speed_lazy
():
def
build_graph
(
x
,
depth
=
5
):
def
build_graph
(
x
,
depth
=
5
):
...
@@ -148,7 +149,6 @@ def test_speed_lazy():
...
@@ -148,7 +149,6 @@ def test_speed_lazy():
a
=
build_graph
(
x
,
steps_a
)
a
=
build_graph
(
x
,
steps_a
)
b
=
build_graph
(
x
,
steps_b
)
b
=
build_graph
(
x
,
steps_b
)
f_a
=
function
([
x
],
a
,
f_a
=
function
([
x
],
a
,
mode
=
Mode
(
optimizer
=
None
,
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
()),
linker
=
linker
()),
...
@@ -179,15 +179,20 @@ def test_speed_lazy():
...
@@ -179,15 +179,20 @@ def test_speed_lazy():
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
)))
(
1000
*
(
t_b
-
t_a
)
/
(
steps_b
-
steps_a
)))
time_linker
(
'vmLinker'
,
vm
.
VM_Linker
)
time_linker
(
'vmLinker'
,
vm
.
VM_Linker
)
time_linker
(
'vmLinker_nogc'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
time_linker
(
'vmLinker_nogc'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
))
if
theano
.
config
.
cxx
:
if
theano
.
config
.
cxx
:
time_linker
(
'vmLinker_C'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
,
time_linker
(
'vmLinker_C'
,
lambda
:
vm
.
VM_Linker
(
allow_gc
=
False
,
use_cloop
=
True
))
use_cloop
=
True
))
def
test_allow_gc_cvm
():
def
test_allow_gc_cvm
():
mode
=
theano
.
config
.
mode
if
mode
in
[
'DEBUG_MODE'
,
'DebugMode'
]:
mode
=
"FAST_RUN"
v
=
theano
.
tensor
.
vector
()
v
=
theano
.
tensor
.
vector
()
f
=
theano
.
function
([
v
],
v
+
1
)
f
=
theano
.
function
([
v
],
v
+
1
,
mode
=
mode
)
f
([
1
])
f
([
1
])
n
=
list
(
f
.
maker
.
fgraph
.
apply_nodes
)[
0
]
.
outputs
[
0
]
n
=
list
(
f
.
maker
.
fgraph
.
apply_nodes
)[
0
]
.
outputs
[
0
]
assert
f
.
fn
.
storage_map
[
n
][
0
]
is
None
assert
f
.
fn
.
storage_map
[
n
][
0
]
is
None
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
aa37b4bb
...
@@ -1123,10 +1123,16 @@ def local_gpu_conv(node):
...
@@ -1123,10 +1123,16 @@ def local_gpu_conv(node):
if
theano
.
sandbox
.
cuda
.
dnn
.
dnn_available
():
if
theano
.
sandbox
.
cuda
.
dnn
.
dnn_available
():
repl
=
local_gpu_conv_legacy
.
transform
(
node
)
repl
=
local_gpu_conv_legacy
.
transform
(
node
)
if
repl
:
if
repl
:
n
=
repl
[
0
]
.
owner
.
inputs
[
0
]
.
owner
if
isinstance
(
node
.
op
,
GpuFromHost
):
assert
isinstance
(
n
.
op
,
GpuConv
)
gpu_conv
=
repl
[
0
]
.
owner
ret
=
theano
.
sandbox
.
cuda
.
dnn
.
local_conv_dnn
.
transform
(
n
)
else
:
gpu_conv
=
repl
[
0
]
.
owner
.
inputs
[
0
]
.
owner
assert
isinstance
(
gpu_conv
.
op
,
GpuConv
)
ret
=
theano
.
sandbox
.
cuda
.
dnn
.
local_conv_dnn
.
transform
(
gpu_conv
)
if
ret
:
if
ret
:
if
isinstance
(
node
.
op
,
GpuFromHost
):
return
ret
else
:
return
[
host_from_gpu
(
ret
[
0
])]
return
[
host_from_gpu
(
ret
[
0
])]
# If dnn isn't avail, the local_gpu_conv_legacy wil introduce the
# If dnn isn't avail, the local_gpu_conv_legacy wil introduce the
# legacy opt. Then the local_conv_gemm will convert it to gemm
# legacy opt. Then the local_conv_gemm will convert it to gemm
...
...
theano/sandbox/cuda/tests/test_conv_cuda_ndarray.py
浏览文件 @
aa37b4bb
...
@@ -747,6 +747,10 @@ def test_dnn_subsample():
...
@@ -747,6 +747,10 @@ def test_dnn_subsample():
class
TestConv2DGPU
(
unittest
.
TestCase
):
class
TestConv2DGPU
(
unittest
.
TestCase
):
conv_ops
=
(
cuda
.
blas
.
GpuConv
,
cuda
.
dnn
.
GpuDnnConvBase
,
cuda
.
blas
.
BaseGpuCorrMM
)
def
test_logical_shapes
(
self
):
def
test_logical_shapes
(
self
):
seed_rng
()
seed_rng
()
for
stride
in
range
(
1
,
4
):
for
stride
in
range
(
1
,
4
):
...
@@ -773,7 +777,7 @@ class TestConv2DGPU(unittest.TestCase):
...
@@ -773,7 +777,7 @@ class TestConv2DGPU(unittest.TestCase):
func
=
theano
.
function
([
a
,
A
],
image_estimate
,
mode
=
theano_mode
)
func
=
theano
.
function
([
a
,
A
],
image_estimate
,
mode
=
theano_mode
)
#theano.printing.debugprint(func,)
#theano.printing.debugprint(func,)
assert
any
([
isinstance
(
node
.
op
,
theano
.
sandbox
.
cuda
.
blas
.
GpuConv
)
assert
any
([
isinstance
(
node
.
op
,
self
.
conv_ops
)
for
node
in
func
.
maker
.
fgraph
.
toposort
()])
for
node
in
func
.
maker
.
fgraph
.
toposort
()])
a_in
=
numpy
.
random
.
randn
(
*
featshp
)
.
astype
(
"float32"
)
a_in
=
numpy
.
random
.
randn
(
*
featshp
)
.
astype
(
"float32"
)
...
...
theano/sandbox/cuda/tests/test_mlp.py
浏览文件 @
aa37b4bb
...
@@ -396,7 +396,11 @@ def build_conv_nnet2_classif(use_gpu, isize, ksize, n_batch,
...
@@ -396,7 +396,11 @@ def build_conv_nnet2_classif(use_gpu, isize, ksize, n_batch,
if
use_gpu
:
if
use_gpu
:
# Check that GpuConv is used
# Check that GpuConv is used
topo
=
train
.
maker
.
fgraph
.
toposort
()
topo
=
train
.
maker
.
fgraph
.
toposort
()
assert
len
([
n
for
n
in
topo
if
isinstance
(
n
.
op
,
tcn
.
blas
.
GpuConv
)])
>
0
conv_ops
=
(
tcn
.
blas
.
GpuConv
,
tcn
.
dnn
.
GpuDnnConvBase
,
tcn
.
blas
.
BaseGpuCorrMM
)
assert
len
([
n
for
n
in
topo
if
isinstance
(
n
.
op
,
conv_ops
)])
>
0
shape_target
=
(
n_batch
,
n_out
)
shape_target
=
(
n_batch
,
n_out
)
return
train
,
params
,
shape_img
,
shape_target
,
mode
return
train
,
params
,
shape_img
,
shape_target
,
mode
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论