Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f80fbcea
提交
f80fbcea
authored
8月 24, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
flake8
上级
2e10599b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
9 行增加
和
4 行删除
+9
-4
graph.py
theano/gof/graph.py
+1
-0
opt.py
theano/gpuarray/opt.py
+5
-3
test_opt.py
theano/gpuarray/tests/test_opt.py
+3
-1
没有找到文件。
theano/gof/graph.py
浏览文件 @
f80fbcea
...
@@ -1449,6 +1449,7 @@ def is_in_ancestors(l_node, f_node):
...
@@ -1449,6 +1449,7 @@ def is_in_ancestors(l_node, f_node):
@contextlib.contextmanager
@contextlib.contextmanager
def
nodes_constructed
():
def
nodes_constructed
():
new_nodes
=
[]
new_nodes
=
[]
def
observer
(
node
):
def
observer
(
node
):
new_nodes
.
append
(
node
)
new_nodes
.
append
(
node
)
Variable
.
append_construction_observer
(
observer
)
Variable
.
append_construction_observer
(
observer
)
...
...
theano/gpuarray/opt.py
浏览文件 @
f80fbcea
...
@@ -260,7 +260,9 @@ def op_lifter(OP, cuda_only=False):
...
@@ -260,7 +260,9 @@ def op_lifter(OP, cuda_only=False):
to_cpu_fn
=
safe_to_cpu
to_cpu_fn
=
safe_to_cpu
else
:
# suppose it is a variable on the GPU
else
:
# suppose it is a variable on the GPU
new_outputs
=
[
new_op
]
new_outputs
=
[
new_op
]
to_cpu_fn
=
lambda
x
:
x
.
transfer
(
'cpu'
)
def
to_cpu_fn
(
x
):
return
x
.
transfer
(
'cpu'
)
# copy stack traces onto gpu outputs
# copy stack traces onto gpu outputs
# also copy the stack traces onto HostFromGpu outputs
# also copy the stack traces onto HostFromGpu outputs
for
old_output
,
new_output
in
zip
(
node
.
outputs
,
new_outputs
):
for
old_output
,
new_output
in
zip
(
node
.
outputs
,
new_outputs
):
...
@@ -673,8 +675,8 @@ def local_gpua_alloc_empty_to_zeros(node):
...
@@ -673,8 +675,8 @@ def local_gpua_alloc_empty_to_zeros(node):
context_name
=
infer_context_name
(
*
node
.
inputs
)
context_name
=
infer_context_name
(
*
node
.
inputs
)
z
=
np
.
asarray
(
0
,
dtype
=
node
.
outputs
[
0
]
.
dtype
)
z
=
np
.
asarray
(
0
,
dtype
=
node
.
outputs
[
0
]
.
dtype
)
with
inherit_stack_trace
(
node
.
outputs
):
with
inherit_stack_trace
(
node
.
outputs
):
return
[
GpuAlloc
(
context_name
)(
as_gpuarray_variable
(
z
,
context_name
),
return
[
GpuAlloc
(
context_name
)(
*
node
.
inputs
)]
as_gpuarray_variable
(
z
,
context_name
),
*
node
.
inputs
)]
optdb
.
register
(
'local_gpua_alloc_empty_to_zeros'
,
optdb
.
register
(
'local_gpua_alloc_empty_to_zeros'
,
theano
.
tensor
.
opt
.
in2out
(
local_gpua_alloc_empty_to_zeros
),
theano
.
tensor
.
opt
.
in2out
(
local_gpua_alloc_empty_to_zeros
),
# After move to gpu and merge2, before inplace.
# After move to gpu and merge2, before inplace.
...
...
theano/gpuarray/tests/test_opt.py
浏览文件 @
f80fbcea
...
@@ -31,7 +31,7 @@ from theano.gpuarray import dnn, blas
...
@@ -31,7 +31,7 @@ from theano.gpuarray import dnn, blas
def
_check_stack_trace
(
thing
):
def
_check_stack_trace
(
thing
):
def
_ops_to_check
(
op
):
def
_ops_to_check
(
op
):
if
not
isinstance
(
op
,
theano
.
gof
.
Op
):
if
not
isinstance
(
op
,
theano
.
gof
.
Op
):
op
=
op
.
op
# assume node
op
=
op
.
op
# assume node
return
not
isinstance
(
op
,
(
theano
.
compile
.
ops
.
Shape_i
,
return
not
isinstance
(
op
,
(
theano
.
compile
.
ops
.
Shape_i
,
theano
.
compile
.
ops
.
Shape
,
theano
.
compile
.
ops
.
Shape
,
theano
.
compile
.
ops
.
DeepCopyOp
,
theano
.
compile
.
ops
.
DeepCopyOp
,
...
@@ -49,6 +49,7 @@ def _check_stack_trace(thing):
...
@@ -49,6 +49,7 @@ def _check_stack_trace(thing):
return
check_stack_trace
(
thing
,
ops_to_check
=
_ops_to_check
,
return
check_stack_trace
(
thing
,
ops_to_check
=
_ops_to_check
,
bug_print
=
"ignore"
)
bug_print
=
"ignore"
)
def
test_local_assert
():
def
test_local_assert
():
x
=
theano
.
tensor
.
fmatrix
()
x
=
theano
.
tensor
.
fmatrix
()
a
=
theano
.
tensor
.
opt
.
assert_op
(
x
,
theano
.
tensor
.
eq
(
x
,
0
)
.
any
())
a
=
theano
.
tensor
.
opt
.
assert_op
(
x
,
theano
.
tensor
.
eq
(
x
,
0
)
.
any
())
...
@@ -282,6 +283,7 @@ def test_rebroadcast():
...
@@ -282,6 +283,7 @@ def test_rebroadcast():
assert
isinstance
(
rebr
.
outputs
[
0
]
.
type
,
GpuArrayType
)
assert
isinstance
(
rebr
.
outputs
[
0
]
.
type
,
GpuArrayType
)
assert
_check_stack_trace
(
f
)
assert
_check_stack_trace
(
f
)
class
TestSpecifyShape
(
test_basic
.
TestSpecifyShape
):
class
TestSpecifyShape
(
test_basic
.
TestSpecifyShape
):
mode
=
mode_with_gpu
mode
=
mode_with_gpu
input_type
=
GpuArrayType
input_type
=
GpuArrayType
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论