Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
91739a95
提交
91739a95
authored
4月 23, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More sum test for gpu reduce with multiple dtype.
上级
d58777b3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
31 行增加
和
14 行删除
+31
-14
test_elemwise.py
theano/sandbox/gpuarray/tests/test_elemwise.py
+10
-2
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+21
-12
没有找到文件。
theano/sandbox/gpuarray/tests/test_elemwise.py
浏览文件 @
91739a95
...
...
@@ -2,9 +2,10 @@ from theano import scalar, gof
from
theano.gof.python25
import
all
,
any
from
theano.tensor.tests.test_elemwise
import
(
test_Broadcast
,
test_DimShuffle
,
test_CAReduce
)
test_CAReduce
,
T_sum_dtype
)
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
rand_gpuarray
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
(
mode_with_gpu
,
rand_gpuarray
)
from
theano.sandbox.gpuarray.elemwise
import
(
GpuElemwise
,
GpuDimShuffle
,
GpuCAReduceCuda
,
GpuCAReduceCPY
)
from
theano.sandbox.gpuarray.type
import
GpuArrayType
...
...
@@ -149,3 +150,10 @@ class test_GpuCAReduceCuda(test_GpuCAReduceCPY):
def
test_perform_nan
(
self
):
return
class
T_gpusum_dtype
(
T_sum_dtype
):
mode
=
mode_with_gpu
.
excluding
(
'local_cut_useless_reduce'
)
op
=
GpuCAReduceCuda
#Currently we don't support reduction on 0 axis
axes
=
[
None
,
0
,
1
,
1
,
[
0
],
[
1
],
[
0
,
1
]]
theano/tensor/tests/test_elemwise.py
浏览文件 @
91739a95
...
...
@@ -717,14 +717,18 @@ class test_IsInf_IsNan(unittest.TestCase):
class
T_sum_dtype
(
unittest
.
TestCase
):
mode
=
theano
.
compile
.
get_default_mode
()
.
excluding
(
'local_cut_useless_reduce'
)
op
=
CAReduce
axes
=
[
None
,
0
,
1
,
[],
[
0
],
[
1
],
[
0
,
1
]]
def
test_sum_default_dtype
(
self
):
"""
Test the default dtype of a sum().
"""
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[],
[
0
],
[
1
],
[
0
,
1
]]
for
idx
,
dtype
in
enumerate
(
imap
(
str
,
theano
.
scalar
.
all_types
)):
axis
=
axes
[
idx
%
len
(
axes
)]
axis
=
self
.
axes
[
idx
%
len
(
self
.
axes
)]
x
=
tensor
.
matrix
(
dtype
=
dtype
)
s
=
x
.
sum
(
axis
=
axis
)
assert
s
.
dtype
==
dict
(
...
...
@@ -735,7 +739,9 @@ class T_sum_dtype(unittest.TestCase):
uint16
=
'uint64'
,
uint32
=
'uint64'
,
)
.
get
(
dtype
,
dtype
)
f
=
theano
.
function
([
x
],
s
)
f
=
theano
.
function
([
x
],
s
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
for
n
in
topo
if
isinstance
(
n
.
op
,
self
.
op
)],
(
topo
,
dtype
)
data
=
numpy
.
random
.
rand
(
3
,
4
)
*
10
data
=
data
.
astype
(
dtype
)
f
(
data
)
...
...
@@ -743,9 +749,8 @@ class T_sum_dtype(unittest.TestCase):
def
test_sum_default_acc_dtype
(
self
):
##Test the default acc_dtype of a sum().
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[],
[
0
],
[
1
],
[
0
,
1
]]
for
idx
,
dtype
in
enumerate
(
imap
(
str
,
theano
.
scalar
.
all_types
)):
axis
=
axes
[
idx
%
len
(
axes
)]
axis
=
self
.
axes
[
idx
%
len
(
self
.
axes
)]
x
=
tensor
.
matrix
(
dtype
=
dtype
)
s
=
x
.
sum
(
axis
=
axis
)
assert
s
.
owner
.
op
.
acc_dtype
==
dict
(
...
...
@@ -758,7 +763,9 @@ class T_sum_dtype(unittest.TestCase):
float32
=
'float64'
,
complex64
=
'complex128'
,
)
.
get
(
dtype
,
dtype
)
f
=
theano
.
function
([
x
],
s
)
f
=
theano
.
function
([
x
],
s
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
for
n
in
topo
if
isinstance
(
n
.
op
,
self
.
op
)],
(
topo
,
dtype
)
data
=
numpy
.
random
.
rand
(
3
,
4
)
*
10
data
=
data
.
astype
(
dtype
)
f
(
data
)
...
...
@@ -769,7 +776,6 @@ class T_sum_dtype(unittest.TestCase):
Test the ability to provide your own output dtype for a sum.
"""
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[],
[
0
],
[
1
],
[
0
,
1
]]
idx
=
0
for
input_dtype
in
imap
(
str
,
theano
.
scalar
.
all_types
):
x
=
tensor
.
matrix
(
dtype
=
input_dtype
)
...
...
@@ -781,11 +787,13 @@ class T_sum_dtype(unittest.TestCase):
output_dtype
.
startswith
(
'complex'
)):
continue
axis
=
axes
[
idx
%
len
(
axes
)]
axis
=
self
.
axes
[
idx
%
len
(
self
.
axes
)]
sum_var
=
x
.
sum
(
dtype
=
output_dtype
,
axis
=
axis
)
assert
sum_var
.
dtype
==
output_dtype
f
=
theano
.
function
([
x
],
sum_var
)
f
=
theano
.
function
([
x
],
sum_var
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
for
n
in
topo
if
isinstance
(
n
.
op
,
self
.
op
)],
(
topo
,
dtype
)
data
=
numpy
.
random
.
rand
(
3
,
4
)
*
10
data
=
data
.
astype
(
input_dtype
)
f
(
data
)
...
...
@@ -801,7 +809,6 @@ class T_sum_dtype(unittest.TestCase):
Test the ability to provide your own accumulator dtype for a sum.
"""
# We try multiple axis combinations even though axis should not matter.
axes
=
[
None
,
0
,
1
,
[],
[
0
],
[
1
],
[
0
,
1
]]
idx
=
0
for
input_dtype
in
imap
(
str
,
theano
.
scalar
.
all_types
):
x
=
tensor
.
matrix
(
dtype
=
input_dtype
)
...
...
@@ -813,7 +820,7 @@ class T_sum_dtype(unittest.TestCase):
acc_dtype
.
startswith
(
'complex'
)):
continue
axis
=
axes
[
idx
%
len
(
axes
)]
axis
=
self
.
axes
[
idx
%
len
(
self
.
axes
)]
# If output_dtype would force a downcast, we expect a TypeError
# We always allow int/uint inputs with float/complex outputs.
upcasted_dtype
=
scalar
.
upcast
(
input_dtype
,
acc_dtype
)
...
...
@@ -839,7 +846,9 @@ class T_sum_dtype(unittest.TestCase):
# Check that the default accumulator precision is sufficient
x
=
theano
.
shared
(
numpy
.
asarray
([
1e8
,
1
,
-
1e8
],
dtype
=
'float32'
))
s
=
x
.
sum
()
f
=
theano
.
function
([],
s
)
f
=
theano
.
function
([],
s
,
mode
=
self
.
mode
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
[
n
for
n
in
topo
if
isinstance
(
n
.
op
,
self
.
op
)],
(
topo
,
dtype
)
s_val
=
f
()
assert
numpy
.
allclose
(
s_val
,
1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论