Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
26cc1f73
提交
26cc1f73
authored
11月 01, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pep8
上级
c6129572
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
33 行删除
+39
-33
test_tensor_op.py
theano/sandbox/cuda/tests/test_tensor_op.py
+39
-33
没有找到文件。
theano/sandbox/cuda/tests/test_tensor_op.py
浏览文件 @
26cc1f73
...
@@ -16,7 +16,7 @@ if cuda.cuda_available == False:
...
@@ -16,7 +16,7 @@ if cuda.cuda_available == False:
raise
SkipTest
(
'Optional package cuda disabled'
)
raise
SkipTest
(
'Optional package cuda disabled'
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpu'
)
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
'gpu'
)
else
:
else
:
...
@@ -26,26 +26,28 @@ else:
...
@@ -26,26 +26,28 @@ else:
def
test_shape_i
():
def
test_shape_i
():
x
=
cuda
.
ftensor3
()
x
=
cuda
.
ftensor3
()
v
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
,
5
),
dtype
=
'float32'
))
v
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
,
5
),
dtype
=
'float32'
))
f
=
theano
.
function
([
x
],
x
.
shape
[
1
])
f
=
theano
.
function
([
x
],
x
.
shape
[
1
])
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
f
(
v
)
==
4
assert
f
(
v
)
==
4
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
assert
len
(
topo
)
==
1
assert
len
(
topo
)
==
1
assert
isinstance
(
topo
[
0
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
0
]
.
op
,
T
.
opt
.
Shape_i
)
def
test_shape
():
def
test_shape
():
x
=
cuda
.
ftensor3
()
x
=
cuda
.
ftensor3
()
v
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
,
5
),
dtype
=
'float32'
))
v
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
,
5
),
dtype
=
'float32'
))
f
=
theano
.
function
([
x
],
x
.
shape
)
f
=
theano
.
function
([
x
],
x
.
shape
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
numpy
.
all
(
f
(
v
)
==
(
3
,
4
,
5
))
assert
numpy
.
all
(
f
(
v
)
==
(
3
,
4
,
5
))
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
if
theano
.
config
.
mode
!=
'FAST_COMPILE'
:
assert
len
(
topo
)
==
4
assert
len
(
topo
)
==
4
assert
isinstance
(
topo
[
0
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
0
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
1
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
2
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
2
]
.
op
,
T
.
opt
.
Shape_i
)
assert
isinstance
(
topo
[
3
]
.
op
,
T
.
opt
.
MakeVector
)
assert
isinstance
(
topo
[
3
]
.
op
,
T
.
opt
.
MakeVector
)
def
test_softmax_optimizations
():
def
test_softmax_optimizations
():
from
theano.tensor.nnet.nnet
import
softmax
,
crossentropy_categorical_1hot
from
theano.tensor.nnet.nnet
import
softmax
,
crossentropy_categorical_1hot
...
@@ -66,16 +68,17 @@ def test_softmax_optimizations():
...
@@ -66,16 +68,17 @@ def test_softmax_optimizations():
assert
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
cuda
.
host_from_gpu
assert
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
cuda
.
host_from_gpu
assert
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
cuda
.
nnet
.
gpu_crossentropy_softmax_argmax_1hot_with_bias
assert
fgraph
.
outputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
]
.
owner
.
op
==
cuda
.
nnet
.
gpu_crossentropy_softmax_argmax_1hot_with_bias
def
test_may_share_memory_cuda
():
def
test_may_share_memory_cuda
():
from
theano.misc.may_share_memory
import
may_share_memory
from
theano.misc.may_share_memory
import
may_share_memory
a
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
),
dtype
=
'float32'
))
a
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
),
dtype
=
'float32'
))
b
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
),
dtype
=
'float32'
))
b
=
cuda
.
CudaNdarray
(
numpy
.
zeros
((
3
,
4
),
dtype
=
'float32'
))
na
=
numpy
.
zeros
((
3
,
4
))
na
=
numpy
.
zeros
((
3
,
4
))
nb
=
numpy
.
zeros
((
3
,
4
))
nb
=
numpy
.
zeros
((
3
,
4
))
va
=
a
.
view
()
va
=
a
.
view
()
vb
=
b
.
view
()
vb
=
b
.
view
()
ra
=
a
.
reshape
((
4
,
3
))
ra
=
a
.
reshape
((
4
,
3
))
rb
=
b
.
reshape
((
4
,
3
))
rb
=
b
.
reshape
((
4
,
3
))
#can't test the transpose as ta._strides = is not implemented
#can't test the transpose as ta._strides = is not implemented
#manual transpose of a
#manual transpose of a
...
@@ -84,25 +87,28 @@ def test_may_share_memory_cuda():
...
@@ -84,25 +87,28 @@ def test_may_share_memory_cuda():
#elem_size=elem_size = numpy.zeros(0,dtype=a.dtype).dtype.itemsize
#elem_size=elem_size = numpy.zeros(0,dtype=a.dtype).dtype.itemsize
#ta.gpudata += ta.size*elem_size
#ta.gpudata += ta.size*elem_size
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),(
b
,
b
,
True
),(
a
,
b
,
False
),
for
a_
,
b_
,
rep
in
[(
a
,
a
,
True
),
(
b
,
b
,
True
),
(
a
,
b
,
False
),
(
a
,
na
,
False
),(
b
,
nb
,
False
),(
na
,
b
,
False
),(
nb
,
a
,
False
),
(
a
,
na
,
False
),
(
b
,
nb
,
False
),
(
a
,
va
,
True
),(
b
,
vb
,
True
),(
va
,
b
,
False
),(
a
,
vb
,
False
),
(
na
,
b
,
False
),
(
nb
,
a
,
False
),
(
a
,
ra
,
True
),(
b
,
rb
,
True
),(
ra
,
b
,
False
),(
a
,
rb
,
False
),
(
a
,
va
,
True
),
(
b
,
vb
,
True
),
(
va
,
b
,
False
),
(
a
,
vb
,
False
),
(
a
,
ra
,
True
),
(
b
,
rb
,
True
),
(
ra
,
b
,
False
),
(
a
,
rb
,
False
),
]:
]:
assert
may_share_memory
(
a_
,
b_
)
==
rep
assert
may_share_memory
(
a_
,
b_
)
==
rep
assert
may_share_memory
(
b_
,
a_
)
==
rep
assert
may_share_memory
(
b_
,
a_
)
==
rep
#test that it raise error when needed.
#test that it raise error when needed.
for
a_
,
b_
,
rep
in
[(
a
,(
0
,),
False
),(
a
,
1
,
False
),(
a
,
None
,
False
)]:
for
a_
,
b_
,
rep
in
[(
a
,
(
0
,),
False
),
(
a
,
1
,
False
),
(
a
,
None
,
False
)]:
assert
may_share_memory
(
a_
,
b_
,
False
)
==
rep
assert
may_share_memory
(
a_
,
b_
,
False
)
==
rep
assert
may_share_memory
(
b_
,
a_
,
False
)
==
rep
assert
may_share_memory
(
b_
,
a_
,
False
)
==
rep
try
:
try
:
may_share_memory
(
a_
,
b_
)
may_share_memory
(
a_
,
b_
)
raise
Exception
(
"An error was expected"
)
raise
Exception
(
"An error was expected"
)
except
TypeError
:
except
TypeError
:
pass
pass
try
:
try
:
may_share_memory
(
b_
,
a_
)
may_share_memory
(
b_
,
a_
)
raise
Exception
(
"An error was expected"
)
raise
Exception
(
"An error was expected"
)
except
TypeError
:
except
TypeError
:
pass
pass
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论