Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7e241005
提交
7e241005
authored
2月 02, 2015
作者:
Pierre Luc Carrier
提交者:
--global
6月 01, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimizer in progress. This commit is just to allow Fred to give some feedback.
上级
4c4b7cc4
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
53 行增加
和
0 行删除
+53
-0
opt.py
theano/sandbox/cuda/opt.py
+38
-0
test_breakpoint.py
theano/tests/test_breakpoint.py
+15
-0
没有找到文件。
theano/sandbox/cuda/opt.py
浏览文件 @
7e241005
...
@@ -63,6 +63,7 @@ from theano.tensor import nlinalg
...
@@ -63,6 +63,7 @@ from theano.tensor import nlinalg
from
theano.tensor
import
slinalg
from
theano.tensor
import
slinalg
from
theano.tensor.nnet.Conv3D
import
Conv3D
from
theano.tensor.nnet.Conv3D
import
Conv3D
from
theano.tests.breakpoint
import
PdbBreakpoint
try
:
try
:
# We need to be able to import this file even if cuda isn't avail.
# We need to be able to import this file even if cuda isn't avail.
...
@@ -1140,6 +1141,43 @@ def local_gpu_print_op(node):
...
@@ -1140,6 +1141,43 @@ def local_gpu_print_op(node):
return
[
host_from_gpu
(
new_op
(
gpu_x
))]
return
[
host_from_gpu
(
new_op
(
gpu_x
))]
return
False
return
False
@register_opt
()
@local_optimizer
([
PdbBreakpoint
])
def
local_gpu_pdbbreakpoint_op
(
node
):
if
isinstance
(
node
.
op
,
PdbBreakpoint
):
old_inputs
=
node
.
inputs
# Obtain the inputs to the new op. The condition (first input) should
# be left on the host but the other inputs can be taken from the GPU.
new_inputs
=
old_inputs
[:
1
]
for
inp
in
old_inputs
[
1
:]:
if
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
):
# Take the input directly from the gpu
new_inputs
.
append
(
inp
.
owner
.
inputs
[
0
])
else
:
new_inputs
.
append
(
inp
)
# Only proceed further if one of the outputs to the op was a
# HostFromGpu
if
new_inputs
[
1
:]
==
old_inputs
[
1
:]:
return
False
# Apply the op on the new inputs
new_outputs
=
node
.
op
(
*
new_inputs
)
# For every output of the new op for which we took the corresponding
# input from the GPU instead of the host, we need to transfer the
# output back to the host before returning it.
for
i
in
range
(
len
(
new_outputs
)):
inp
=
old_inputs
[
i
+
1
]
if
(
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
)):
new_outputs
[
i
]
=
host_from_gpu
(
new_outputs
[
i
])
return
new_outputs
return
False
def
cast
(
x
,
dtype
):
def
cast
(
x
,
dtype
):
stype
=
scal
.
Scalar
(
dtype
)
stype
=
scal
.
Scalar
(
dtype
)
...
...
theano/tests/test_breakpoint.py
浏览文件 @
7e241005
...
@@ -59,6 +59,21 @@ class TestPdbBreakpoint(utt.InferShapeTester):
...
@@ -59,6 +59,21 @@ class TestPdbBreakpoint(utt.InferShapeTester):
for
i
in
range
(
len
(
gradients
)):
for
i
in
range
(
len
(
gradients
)):
numpy
.
testing
.
assert_allclose
(
gradients
[
i
],
expected_gradients
[
i
])
numpy
.
testing
.
assert_allclose
(
gradients
[
i
],
expected_gradients
[
i
])
def
test_fprop
(
self
):
input1_value
=
numpy
.
arange
(
9
)
.
reshape
(
3
,
3
)
.
astype
(
"float32"
)
input2_value
=
10.0
fct
=
theano
.
function
([
self
.
input1
,
self
.
input2
],
[
self
.
monitored_input1
,
self
.
monitored_input2
])
output
=
fct
(
input1_value
,
input2_value
)[:
-
1
]
import
pdb
pdb
.
set_trace
()
expected_output
=
[
numpy
.
ones
((
3
,
3
),
dtype
=
"float32"
),
numpy
.
array
(
1.
,
dtype
=
"float32"
)]
def
test_connection_pattern
(
self
):
def
test_connection_pattern
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论