Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
697d3eb7
提交
697d3eb7
authored
3月 30, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update test for CudaNdarray__setitem
上级
83ec4038
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
61 行增加
和
61 行删除
+61
-61
test_cuda_ndarray.py
theano/sandbox/cuda/tests/test_cuda_ndarray.py
+61
-61
没有找到文件。
theano/sandbox/cuda/tests/test_cuda_ndarray.py
浏览文件 @
697d3eb7
...
@@ -630,13 +630,9 @@ def test_setitem_matrixvector1():
...
@@ -630,13 +630,9 @@ def test_setitem_matrixvector1():
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
#test direct transfert from numpy
#test direct transfert from numpy
try
:
_a
[:,
1
]
=
b
*
100
_a
[:,
1
]
=
b
*
100
a
[:,
1
]
=
b
*
100
a
[:,
1
]
=
b
*
100
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
raise
Exception
(
"CudaNdarray.__setitem__ should have returned an error"
)
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
except
NotImplementedError
,
e
:
pass
row
=
theano
.
_asarray
([
777
,
888
,
999
],
dtype
=
'float32'
)
row
=
theano
.
_asarray
([
777
,
888
,
999
],
dtype
=
'float32'
)
_a
[
1
,:]
=
row
_a
[
1
,:]
=
row
...
@@ -659,13 +655,9 @@ def test_setitem_matrix_tensor3():
...
@@ -659,13 +655,9 @@ def test_setitem_matrix_tensor3():
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
#test direct transfert from numpy
#test direct transfert from numpy
try
:
_a
[:,
1
,
1
]
=
b
*
100
_a
[:,
1
,
1
]
=
b
*
100
a
[:,
1
,
1
]
=
b
*
100
a
[:,
1
,
1
]
=
b
*
100
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
raise
Exception
(
"CudaNdarray.__setitem__ should have returned an error"
)
assert
numpy
.
allclose
(
a
,
numpy
.
asarray
(
_a
))
except
NotImplementedError
:
pass
row
=
theano
.
_asarray
([
777
,
888
,
999
],
dtype
=
'float32'
)
row
=
theano
.
_asarray
([
777
,
888
,
999
],
dtype
=
'float32'
)
_a
[
1
,
1
,:]
=
row
_a
[
1
,
1
,:]
=
row
...
@@ -714,7 +706,7 @@ def test_setitem_matrix_bad_ndim():
...
@@ -714,7 +706,7 @@ def test_setitem_matrix_bad_ndim():
# attempt to assign the ndarray b with setitem
# attempt to assign the ndarray b with setitem
_a
[:,:,
1
]
=
_b
_a
[:,:,
1
]
=
_b
assert
False
assert
False
except
NotImplemented
Error
,
e
:
except
Value
Error
,
e
:
#print e
#print e
assert
True
assert
True
...
@@ -723,7 +715,7 @@ def test_setitem_matrix_bad_ndim():
...
@@ -723,7 +715,7 @@ def test_setitem_matrix_bad_ndim():
# attempt to assign the ndarray b with setitem
# attempt to assign the ndarray b with setitem
_a
[
1
,:,:]
=
b
_a
[
1
,:,:]
=
b
assert
False
assert
False
except
NotImplemented
Error
,
e
:
except
Value
Error
,
e
:
#print e
#print e
assert
True
assert
True
...
@@ -806,7 +798,7 @@ def test_setitem_broadcast():
...
@@ -806,7 +798,7 @@ def test_setitem_broadcast():
a
[:,:,
1
]
=
b
.
reshape
((
1
,
3
))
a
[:,:,
1
]
=
b
.
reshape
((
1
,
3
))
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
#This is not supported for now.
def
test_setitem_broadcast_numpy
():
def
test_setitem_broadcast_numpy
():
#test scalar to vector without stride
#test scalar to vector without stride
a
=
numpy
.
arange
(
3
)
a
=
numpy
.
arange
(
3
)
...
@@ -814,73 +806,81 @@ def test_setitem_broadcast_numpy():
...
@@ -814,73 +806,81 @@ def test_setitem_broadcast_numpy():
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
b
=
theano
.
_asarray
(
9
,
dtype
=
'float32'
)
b
=
theano
.
_asarray
(
9
,
dtype
=
'float32'
)
try
:
_a
[:]
=
b
.
reshape
((
1
,))
_a
[:]
=
b
.
reshape
((
1
,))
a
[:]
=
b
.
reshape
((
1
,))
a
[:]
=
b
.
reshape
((
1
,))
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
assert
False
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
except
ValueError
:
pass
#test vector to matrice without stride
#test vector to matrice without stride
a
=
numpy
.
arange
(
9
)
a
=
numpy
.
arange
(
9
)
a
.
resize
((
3
,
3
))
a
.
resize
((
3
,
3
))
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
try
:
b
=
theano
.
_asarray
([
7
,
8
,
9
],
dtype
=
'float32'
)
b
=
theano
.
_asarray
([
7
,
8
,
9
],
dtype
=
'float32'
)
_a
[:,
:]
=
b
.
reshape
((
1
,
3
))
_a
[:,:]
=
b
.
reshape
((
1
,
3
))
a
[:,
:]
=
b
.
reshape
((
1
,
3
))
a
[:,:]
=
b
.
reshape
((
1
,
3
))
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
assert
False
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
except
ValueError
:
pass
#test vector to matrice with stride
#test vector to matrice with stride
a
=
numpy
.
arange
(
27
)
a
=
numpy
.
arange
(
27
)
a
.
resize
((
3
,
3
,
3
))
a
.
resize
((
3
,
3
,
3
))
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
try
:
b
=
theano
.
_asarray
([[
7
,
8
,
9
],
[
10
,
11
,
12
]],
dtype
=
'float32'
)
b
=
theano
.
_asarray
([[
7
,
8
,
9
],[
10
,
11
,
12
]],
dtype
=
'float32'
)
b
=
b
[
0
]
b
=
b
[
0
]
_a
[
1
,
:,
:]
=
b
.
reshape
((
1
,
3
))
_a
[
1
,:,:]
=
b
.
reshape
((
1
,
3
))
a
[
1
,
:,
:]
=
b
.
reshape
((
1
,
3
))
a
[
1
,:,:]
=
b
.
reshape
((
1
,
3
))
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
assert
False
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
except
ValueError
:
pass
# this also fails for the moment
# this also fails for the moment
def
test_setitem_rightvalue_ndarray_fails
():
def
test_setitem_rightvalue_ndarray_fails
():
"""
"""
Now we don't automatically add dimensions to broadcast
Now we don't automatically add dimensions to broadcast
"""
"""
a
=
numpy
.
arange
(
27
)
a
=
numpy
.
arange
(
3
*
4
*
5
)
a
.
resize
((
3
,
3
,
3
))
a
.
resize
((
3
,
4
,
5
))
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
a
=
theano
.
_asarray
(
a
,
dtype
=
'float32'
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
_a
=
cuda_ndarray
.
CudaNdarray
(
a
)
b
=
theano
.
_asarray
([
7
,
8
,
9
],
dtype
=
'float32'
)
b
=
theano
.
_asarray
([
7
,
8
,
9
,
10
],
dtype
=
'float32'
)
_b
=
cuda_ndarray
.
CudaNdarray
(
b
)
_b
=
cuda_ndarray
.
CudaNdarray
(
b
)
b5
=
theano
.
_asarray
([
7
,
8
,
9
,
10
,
11
],
dtype
=
'float32'
)
_b5
=
cuda_ndarray
.
CudaNdarray
(
b
)
# attempt to assign the ndarray b with setitem
_a
[:,
:,
1
]
=
_b
a
[:,
:,
1
]
=
b
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
#test direct transfert from numpy to contiguous region
# attempt to assign the ndarray b with setitem
# same number of dim
mat
=
numpy
.
random
.
rand
(
4
,
5
)
.
astype
(
'float32'
)
_a
[
2
,
:,
:]
=
mat
a
[
2
,
:,
:]
=
mat
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
# without same number of dim
try
:
try
:
# attempt to assign the ndarray b with setitem
_a
[
0
,
:,
:]
=
mat
_a
[:,:,
1
]
=
_b
#a[0, :, :] = mat
assert
False
#assert numpy.allclose(numpy.asarray(_a), a)
except
NotImplementedError
,
e
:
except
ValueError
,
e
:
#print e
pass
assert
True
#test direct transfert from numpy with broadcast
_a
[
0
,
:,
:]
=
b5
a
[
0
,
:,
:]
=
b5
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
#test direct transfert from numpy to not contiguous region
# attempt to assign the ndarray b with setitem
_a
[:,
:,
2
]
=
b
a
[:,
:,
2
]
=
b
assert
numpy
.
allclose
(
numpy
.
asarray
(
_a
),
a
)
#test direct transfert from numpy
try
:
# attempt to assign the ndarray b with setitem
_a
[:,:,
1
]
=
b
assert
False
except
NotImplementedError
,
e
:
#print e
assert
True
def
test_zeros_basic
():
def
test_zeros_basic
():
for
shp
in
[(
3
,
4
,
5
),
(
300
,),
(),
(
0
,
7
)]:
for
shp
in
[(
3
,
4
,
5
),
(
300
,),
(),
(
0
,
7
)]:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论