Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c5dc5576
提交
c5dc5576
authored
4月 23, 2014
作者:
Arnaud Bergeron
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add test for Rebroadcast on GpuArrayVariables
上级
332b691e
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
21 行删除
+23
-21
test_opt.py
theano/sandbox/gpuarray/tests/test_opt.py
+23
-21
没有找到文件。
theano/sandbox/gpuarray/tests/test_opt.py
浏览文件 @
c5dc5576
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
tensor
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
import
theano.sandbox.gpuarray
from
theano.sandbox.gpuarray.type
import
GpuArrayType
from
theano.sandbox.gpuarray.basic_ops
import
GpuAlloc
,
GpuReshape
,
gpu_alloc
from
theano.sandbox.gpuarray.basic_ops
import
GpuAlloc
,
GpuReshape
,
gpu_alloc
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduceCuda
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduceCuda
import
theano.sandbox.gpuarray
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
(
rand_gpuarray
,
mode_with_gpu
,
mode_without_gpu
)
from
theano.tests.unittest_tools
import
SkipTest
from
theano.tests.unittest_tools
import
SkipTest
if
theano
.
sandbox
.
gpuarray
.
pygpu
is
None
:
raise
SkipTest
(
"pygpu not installed"
)
import
theano.sandbox.cuda
as
cuda_ndarray
if
cuda_ndarray
.
cuda_available
and
not
theano
.
sandbox
.
gpuarray
.
pygpu_activated
:
if
not
cuda_ndarray
.
use
.
device_number
:
cuda_ndarray
.
use
(
'gpu'
)
theano
.
sandbox
.
gpuarray
.
init_dev
(
'cuda'
)
if
not
theano
.
sandbox
.
gpuarray
.
pygpu_activated
:
raise
SkipTest
(
"pygpu disabled"
)
if
theano
.
config
.
mode
==
'FAST_COMPILE'
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
including
(
'gpuarray'
)
.
excluding
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_mode
(
'FAST_RUN'
)
.
excluding
(
'gpuarray'
)
else
:
mode_with_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
including
(
'gpuarray'
)
.
excluding
(
'gpu'
)
mode_without_gpu
=
theano
.
compile
.
mode
.
get_default_mode
()
.
excluding
(
'gpuarray'
)
def
test_flatten
():
def
test_flatten
():
m
=
theano
.
tensor
.
fmatrix
()
m
=
theano
.
tensor
.
fmatrix
()
f
=
theano
.
function
([
m
],
m
.
flatten
(),
mode
=
mode_with_gpu
)
f
=
theano
.
function
([
m
],
m
.
flatten
(),
mode
=
mode_with_gpu
)
...
@@ -104,3 +89,20 @@ def test_local_gpualloc_memset_0():
...
@@ -104,3 +89,20 @@ def test_local_gpualloc_memset_0():
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAlloc
)
assert
isinstance
(
topo
[
0
]
.
op
,
GpuAlloc
)
assert
not
topo
[
0
]
.
op
.
memset_0
assert
not
topo
[
0
]
.
op
.
memset_0
assert
(
numpy
.
asarray
(
f
(
2
))
==
1
)
.
all
()
assert
(
numpy
.
asarray
(
f
(
2
))
==
1
)
.
all
()
def
test_rebroadcast
():
d
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
'float32'
)
v
=
theano
.
tensor
.
fmatrix
()
up
=
tensor
.
unbroadcast
(
v
.
sum
()
.
dimshuffle
(
'x'
,
'x'
),
0
,
1
)
f
=
theano
.
function
([
v
],
[
up
],
mode
=
mode_with_gpu
)
f
(
d
)
topo
=
f
.
maker
.
fgraph
.
toposort
()
rebrs
=
[
node
for
node
in
topo
if
isinstance
(
node
.
op
,
tensor
.
Rebroadcast
)]
assert
len
(
rebrs
)
==
1
rebr
=
rebrs
[
0
]
assert
isinstance
(
rebr
.
inputs
[
0
]
.
type
,
GpuArrayType
)
assert
isinstance
(
rebr
.
outputs
[
0
]
.
type
,
GpuArrayType
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论