Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
91f08497
提交
91f08497
authored
12月 05, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3731 from nouiz/gpualloc_empty
Lift GpuAllocEmpty in the new GPU back-end.
上级
52185277
f1a61158
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
60 行增加
和
29 行删除
+60
-29
op.py
theano/gof/op.py
+11
-0
test_graph.py
theano/gof/tests/test_graph.py
+5
-2
test_opt.py
theano/sandbox/cuda/tests/test_opt.py
+1
-1
opt.py
theano/sandbox/gpuarray/opt.py
+9
-0
test_opt.py
theano/sandbox/gpuarray/tests/test_opt.py
+25
-1
test_linalg.py
theano/sandbox/linalg/tests/test_linalg.py
+3
-24
test_corr.py
theano/tensor/nnet/tests/test_corr.py
+2
-0
test_ifelse.py
theano/tests/test_ifelse.py
+4
-1
没有找到文件。
theano/gof/op.py
浏览文件 @
91f08497
...
@@ -779,6 +779,17 @@ class Op(utils.object2, PureOp, CLinkerOp):
...
@@ -779,6 +779,17 @@ class Op(utils.object2, PureOp, CLinkerOp):
def
_props
(
self
):
def
_props
(
self
):
return
tuple
(
getattr
(
self
,
a
)
for
a
in
self
.
__props__
)
return
tuple
(
getattr
(
self
,
a
)
for
a
in
self
.
__props__
)
def
_props_dict
(
self
):
"""This return a dict of all ``__props__`` key-> value.
This is useful in optimization to swap op that should have the
same props. This help detect error that the new op have at
least all the original props.
"""
return
dict
([(
a
,
getattr
(
self
,
a
))
for
a
in
self
.
__props__
])
def
__hash__
(
self
):
def
__hash__
(
self
):
if
hasattr
(
self
,
'__props__'
):
if
hasattr
(
self
,
'__props__'
):
return
hash
((
type
(
self
),
self
.
_props
()))
return
hash
((
type
(
self
),
self
.
_props
()))
...
...
theano/gof/tests/test_graph.py
浏览文件 @
91f08497
from
__future__
import
print_function
from
__future__
import
print_function
from
itertools
import
count
import
pickle
import
pickle
import
unittest
import
unittest
import
numpy
from
itertools
import
count
from
nose.plugins.skip
import
SkipTest
import
numpy
from
theano
import
(
from
theano
import
(
sparse
,
sparse
,
...
@@ -361,6 +362,8 @@ class TestAutoName:
...
@@ -361,6 +362,8 @@ class TestAutoName:
def
test_sparsevariable
(
self
):
def
test_sparsevariable
(
self
):
# Get counter value
# Get counter value
if
not
sparse
.
enable_sparse
:
raise
SkipTest
(
'Optional package SciPy not installed'
)
autoname_id
=
next
(
Variable
.
__count__
)
autoname_id
=
next
(
Variable
.
__count__
)
Variable
.
__count__
=
count
(
autoname_id
)
Variable
.
__count__
=
count
(
autoname_id
)
r1
=
sparse
.
csc_matrix
(
name
=
'x'
,
dtype
=
'float32'
)
r1
=
sparse
.
csc_matrix
(
name
=
'x'
,
dtype
=
'float32'
)
...
...
theano/sandbox/cuda/tests/test_opt.py
浏览文件 @
91f08497
...
@@ -323,7 +323,7 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
...
@@ -323,7 +323,7 @@ def test_opt_gpujoin_joinvectors_elemwise_then_minusone():
assert
isinstance
(
graph_nodes
[
-
2
]
.
op
,
cuda
.
GpuSubtensor
)
assert
isinstance
(
graph_nodes
[
-
2
]
.
op
,
cuda
.
GpuSubtensor
)
assert
isinstance
(
graph_nodes
[
-
3
]
.
op
,
cuda
.
GpuJoin
)
assert
isinstance
(
graph_nodes
[
-
3
]
.
op
,
cuda
.
GpuJoin
)
concat
=
numpy
.
concatenate
([
numpy
.
cos
(
_a
),
numpy
.
sin
(
_b
)],
axis
=
1
)
concat
=
numpy
.
concatenate
([
numpy
.
cos
(
_a
),
numpy
.
sin
(
_b
)],
axis
=
0
)
concat
=
concat
[:
-
1
]
concat
=
concat
[:
-
1
]
assert
numpy
.
allclose
(
numpy
.
asarray
(
f
()),
concat
)
assert
numpy
.
allclose
(
numpy
.
asarray
(
f
()),
concat
)
...
...
theano/sandbox/gpuarray/opt.py
浏览文件 @
91f08497
...
@@ -273,6 +273,15 @@ def local_gpuaalloc(node, context_name):
...
@@ -273,6 +273,15 @@ def local_gpuaalloc(node, context_name):
return
GpuAlloc
(
context_name
)(
*
node
.
inputs
)
return
GpuAlloc
(
context_name
)(
*
node
.
inputs
)
@register_opt
(
'fast_compile'
)
@op_lifter
([
tensor
.
AllocEmpty
])
def
local_gpuaallocempty
(
node
,
context_name
):
# We use _props_dict() to make sure that the GPU op know all the
# CPU op props.
return
GpuAllocEmpty
(
context_name
=
context_name
,
**
node
.
op
.
_props_dict
())(
*
node
.
inputs
)
@register_opt
()
@register_opt
()
@local_optimizer
([
GpuAlloc
])
@local_optimizer
([
GpuAlloc
])
def
local_gpualloc_memset_0
(
node
):
def
local_gpualloc_memset_0
(
node
):
...
...
theano/sandbox/gpuarray/tests/test_opt.py
浏览文件 @
91f08497
...
@@ -9,7 +9,8 @@ from theano.tensor.tests import test_basic
...
@@ -9,7 +9,8 @@ from theano.tensor.tests import test_basic
import
theano.sandbox.gpuarray
import
theano.sandbox.gpuarray
from
..
import
basic_ops
from
..
import
basic_ops
from
..type
import
GpuArrayType
,
gpuarray_shared_constructor
,
get_context
from
..type
import
GpuArrayType
,
gpuarray_shared_constructor
,
get_context
from
..basic_ops
import
GpuAlloc
,
GpuReshape
,
GpuFromHost
,
host_from_gpu
from
..basic_ops
import
(
GpuAlloc
,
GpuAllocEmpty
,
GpuReshape
,
GpuFromHost
,
host_from_gpu
)
from
..elemwise
import
GpuCAReduceCuda
,
GpuCAReduceCPY
,
GpuElemwise
from
..elemwise
import
GpuCAReduceCuda
,
GpuCAReduceCPY
,
GpuElemwise
from
..subtensor
import
GpuSubtensor
from
..subtensor
import
GpuSubtensor
...
@@ -151,6 +152,29 @@ def test_local_gpualloc_memset_0():
...
@@ -151,6 +152,29 @@ def test_local_gpualloc_memset_0():
assert
(
numpy
.
asarray
(
f
(
2
))
==
1
)
.
all
()
assert
(
numpy
.
asarray
(
f
(
2
))
==
1
)
.
all
()
def
test_local_gpualloc_empty
():
i
=
theano
.
tensor
.
iscalar
()
ii
=
theano
.
tensor
.
iscalar
()
# Test with vector
a
=
tensor
.
AllocEmpty
(
'float32'
)(
i
)
f
=
theano
.
function
([
i
],
a
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
# This return not initilized data, so we can only check the shape
assert
f
(
3
)
.
shape
==
(
3
,)
# Test with matrix
a
=
tensor
.
AllocEmpty
(
'float32'
)(
i
,
ii
)
f
=
theano
.
function
([
i
,
ii
],
a
,
mode
=
mode_with_gpu
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
topo
)
==
2
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAllocEmpty
)
# This return not initilized data, so we can only check the shape
assert
f
(
3
,
4
)
.
shape
==
(
3
,
4
)
def
test_rebroadcast
():
def
test_rebroadcast
():
d
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
'float32'
)
d
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
'float32'
)
v
=
theano
.
tensor
.
fmatrix
()
v
=
theano
.
tensor
.
fmatrix
()
...
...
theano/sandbox/linalg/tests/test_linalg.py
浏览文件 @
91f08497
import
unittest
import
numpy
import
numpy
import
numpy.linalg
import
numpy.linalg
from
numpy.testing
import
assert_array_almost_equal
from
numpy.testing
import
dec
,
assert_array_equal
,
assert_allclose
from
numpy
import
inf
import
theano
import
theano
from
theano
import
tensor
,
function
from
theano
import
tensor
,
function
...
@@ -16,35 +11,17 @@ from theano.tensor.nlinalg import MatrixInverse
...
@@ -16,35 +11,17 @@ from theano.tensor.nlinalg import MatrixInverse
from
theano.tensor
import
DimShuffle
from
theano.tensor
import
DimShuffle
# The one in comment are not tested...
# The one in comment are not tested...
from
theano.sandbox.linalg.ops
import
(
cholesky
,
from
theano.sandbox.linalg.ops
import
(
Cholesky
,
# op class
Cholesky
,
# op class
CholeskyGrad
,
matrix_inverse
,
matrix_inverse
,
pinv
,
Solve
,
Solve
,
solve
,
solve
,
diag
,
ExtractDiag
,
extract_diag
,
AllocDiag
,
alloc_diag
,
det
,
svd
,
qr
,
# PSD_hint,
# PSD_hint,
trace
,
matrix_dot
,
spectral_radius_bound
,
spectral_radius_bound
,
imported_scipy
,
imported_scipy
,
Eig
,
inv_as_solve
,
inv_as_solve
,
norm
)
)
from
theano.sandbox.linalg
import
eig
,
eigh
,
eigvalsh
from
theano.tests.unittest_tools
import
attr
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
nose.tools
import
assert_raises
def
test_rop_lop
():
def
test_rop_lop
():
...
@@ -156,6 +133,8 @@ def test_transinv_to_invtrans():
...
@@ -156,6 +133,8 @@ def test_transinv_to_invtrans():
def
test_tag_solve_triangular
():
def
test_tag_solve_triangular
():
if
not
imported_scipy
:
raise
SkipTest
(
"Scipy needed for the Cholesky op."
)
cholesky_lower
=
Cholesky
(
lower
=
True
)
cholesky_lower
=
Cholesky
(
lower
=
True
)
cholesky_upper
=
Cholesky
(
lower
=
False
)
cholesky_upper
=
Cholesky
(
lower
=
False
)
A
=
tensor
.
matrix
(
'A'
)
A
=
tensor
.
matrix
(
'A'
)
...
...
theano/tensor/nnet/tests/test_corr.py
浏览文件 @
91f08497
...
@@ -24,6 +24,8 @@ class TestCorr2D(utt.InferShapeTester):
...
@@ -24,6 +24,8 @@ class TestCorr2D(utt.InferShapeTester):
self
.
filters
.
name
=
'default_filters'
self
.
filters
.
name
=
'default_filters'
if
not
conv
.
imported_scipy_signal
and
theano
.
config
.
cxx
==
""
:
if
not
conv
.
imported_scipy_signal
and
theano
.
config
.
cxx
==
""
:
raise
SkipTest
(
"CorrMM tests need SciPy or a c++ compiler"
)
raise
SkipTest
(
"CorrMM tests need SciPy or a c++ compiler"
)
if
not
theano
.
config
.
blas
.
ldflags
:
raise
SkipTest
(
"CorrMM tests need a BLAS"
)
def
validate
(
self
,
image_shape
,
filter_shape
,
def
validate
(
self
,
image_shape
,
filter_shape
,
border_mode
=
'valid'
,
subsample
=
(
1
,
1
),
border_mode
=
'valid'
,
subsample
=
(
1
,
1
),
...
...
theano/tests/test_ifelse.py
浏览文件 @
91f08497
...
@@ -67,7 +67,10 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -67,7 +67,10 @@ class test_ifelse(unittest.TestCase, utt.TestOptimizationMixin):
y2
=
reduce
(
lambda
x
,
y
:
x
+
y
,
[
y
]
+
list
(
range
(
200
)))
y2
=
reduce
(
lambda
x
,
y
:
x
+
y
,
[
y
]
+
list
(
range
(
200
)))
f
=
theano
.
function
([
c
,
x
,
y
],
ifelse
(
c
,
x
,
y2
),
mode
=
mode
)
f
=
theano
.
function
([
c
,
x
,
y
],
ifelse
(
c
,
x
,
y2
),
mode
=
mode
)
# For not inplace ifelse
# For not inplace ifelse
self
.
assertFunctionContains1
(
f
,
IfElse
(
1
))
ifnode
=
[
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
n
.
op
,
IfElse
)]
assert
len
(
ifnode
)
==
1
assert
not
ifnode
[
0
]
.
op
.
as_view
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
rng
=
numpy
.
random
.
RandomState
(
utt
.
fetch_seed
())
xlen
=
rng
.
randint
(
200
)
xlen
=
rng
.
randint
(
200
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论