Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e95b4eba
提交
e95b4eba
authored
5月 06, 2014
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move print op to the new gpu back-end.
上级
81124da3
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
2 行删除
+35
-2
opt.py
theano/sandbox/gpuarray/opt.py
+16
-0
test_opt.py
theano/sandbox/gpuarray/tests/test_opt.py
+19
-2
没有找到文件。
theano/sandbox/gpuarray/opt.py
浏览文件 @
e95b4eba
...
@@ -288,6 +288,22 @@ def local_gpua_specifyShape(node):
...
@@ -288,6 +288,22 @@ def local_gpua_specifyShape(node):
return
tensor
.
specify_shape
(
*
inp
)
return
tensor
.
specify_shape
(
*
inp
)
def
gpu_print_wrapper
(
op
,
cnda
):
op
.
old_op
.
global_fn
(
op
.
old_op
,
numpy
.
asarray
(
cnda
))
@register_opt
()
@op_lifter
([
tensor
.
printing
.
Print
])
def
local_gpu_print_op
(
node
):
x
,
=
node
.
inputs
if
x
.
owner
and
isinstance
(
x
.
owner
.
op
,
HostFromGpu
):
gpu_x
,
=
x
.
owner
.
inputs
new_op
=
node
.
op
.
__class__
(
global_fn
=
gpu_print_wrapper
)
new_op
.
old_op
=
node
.
op
return
new_op
(
gpu_x
)
return
False
@register_opt
()
@register_opt
()
@op_lifter
([
tensor
.
Join
])
@op_lifter
([
tensor
.
Join
])
def
local_gpua_join
(
node
):
def
local_gpua_join
(
node
):
...
...
theano/sandbox/gpuarray/tests/test_opt.py
浏览文件 @
e95b4eba
...
@@ -5,8 +5,9 @@ from theano import tensor
...
@@ -5,8 +5,9 @@ from theano import tensor
from
theano.tests
import
unittest_tools
as
utt
from
theano.tests
import
unittest_tools
as
utt
import
theano.sandbox.gpuarray
import
theano.sandbox.gpuarray
from
theano.sandbox.gpuarray.type
import
GpuArrayType
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
(
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduceCuda
GpuAlloc
,
GpuReshape
,
gpu_alloc
,
gpu_from_host
,
host_from_gpu
)
from
theano.sandbox.gpuarray.elemwise
import
GpuCAReduceCuda
,
GpuElemwise
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
(
from
theano.sandbox.gpuarray.tests.test_basic_ops
import
(
rand_gpuarray
,
mode_with_gpu
,
mode_without_gpu
rand_gpuarray
,
mode_with_gpu
,
mode_without_gpu
)
)
...
@@ -116,3 +117,19 @@ class TestSpecifyShape(TestSpecifyShape):
...
@@ -116,3 +117,19 @@ class TestSpecifyShape(TestSpecifyShape):
mode
=
mode_with_gpu
mode
=
mode_with_gpu
input_type
=
GpuArrayType
input_type
=
GpuArrayType
pass
pass
def
test_print_op
():
""" Test that print ops don't block gpu optimization"""
b
=
tensor
.
fmatrix
()
f
=
theano
.
function
([
b
],
theano
.
printing
.
Print
()(
b
)
*
2
,
mode
=
mode_with_gpu
)
theano
.
printing
.
debugprint
(
f
)
#print f.maker.fgraph.toposort()
#[GpuFromHost(<TensorType(float32, matrix)>), <theano.printing.Print object at 0x3581210>(GpuFromHost.0), GpuElemwise{mul}(CudaNdarray{[[ 2.]]}, <theano.printing.Print object at 0x3581210>.0), HostFromGpu(GpuElemwise{mul}.0)]
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
topo
[
0
]
.
op
==
gpu_from_host
assert
isinstance
(
topo
[
1
]
.
op
,
theano
.
printing
.
Print
)
assert
isinstance
(
topo
[
2
]
.
op
,
GpuElemwise
)
assert
topo
[
3
]
.
op
==
host_from_gpu
f
(
numpy
.
random
.
random
((
5
,
5
))
.
astype
(
'float32'
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论