Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
05649d91
提交
05649d91
authored
3月 27, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Don't scalar float* elemwise unless the result is needed on the GPU.
上级
0c53fb52
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
0 行删除
+28
-0
opt.py
theano/gpuarray/opt.py
+7
-0
test_opt.py
theano/gpuarray/tests/test_opt.py
+21
-0
没有找到文件。
theano/gpuarray/opt.py
浏览文件 @
05649d91
...
@@ -702,6 +702,13 @@ def local_gpua_elemwise(op, context_name, inputs, outputs):
...
@@ -702,6 +702,13 @@ def local_gpua_elemwise(op, context_name, inputs, outputs):
name
=
'Gpu'
+
name
name
=
'Gpu'
+
name
if
len
(
outputs
)
>
1
:
if
len
(
outputs
)
>
1
:
return
return
# We move float* scalar only if the outputs is used on the GPU.
# This will trigger a backward pass when needed, but will prevent
# many useless transfer to only compute GpuElemwise on scalar.
if
outputs
[
0
]
.
ndim
==
0
and
len
([
c
for
c
,
_
in
outputs
[
0
]
.
clients
if
isinstance
(
c
.
op
,
GpuFromHost
)])
==
0
:
return
have_cuda
=
False
have_cuda
=
False
have_opencl
=
False
have_opencl
=
False
if
inputs
and
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
if
inputs
and
isinstance
(
inputs
[
0
]
.
type
,
GpuArrayType
):
...
...
theano/gpuarray/tests/test_opt.py
浏览文件 @
05649d91
...
@@ -493,6 +493,27 @@ def test_many_arg_elemwise():
...
@@ -493,6 +493,27 @@ def test_many_arg_elemwise():
utt
.
assert_allclose
(
results_gpu
,
results_cpu
)
utt
.
assert_allclose
(
results_gpu
,
results_cpu
)
def
test_not_useless_scalar_gpuelemwise
():
# We don't want to move elemwise on scalar on the GPU when the
# result will be used on the GPU!
with
theano
.
configparser
.
change_flags
(
warn_float64
=
'ignore'
):
X
=
tensor
.
fmatrix
()
x
=
np
.
random
.
randn
(
32
,
32
)
.
astype
(
np
.
float32
)
m1
=
theano
.
shared
(
np
.
random
.
randn
(
32
,
32
)
.
astype
(
np
.
float32
))
loss
=
(
X
-
tensor
.
dot
(
X
,
m1
))
.
norm
(
L
=
2
)
lr0
=
.
001
grad
=
tensor
.
grad
(
loss
,
m1
)
train
=
theano
.
function
(
inputs
=
[
X
],
updates
=
[(
m1
,
m1
-
lr1
*
grad
)],
mode
=
mode_with_gpu
)
train
(
x
)
topo
=
train
.
maker
.
fgraph
.
toposort
()
gemms
=
[
app
for
app
in
topo
if
isinstance
(
app
.
op
,
GpuGemm
)]
assert
len
(
gemms
)
==
1
assert
isinstance
(
gemms
[
0
]
.
inputs
[
1
]
.
owner
.
op
,
tensor
.
Elemwise
)
def
test_local_lift_abstractconv_gpu_shape
():
def
test_local_lift_abstractconv_gpu_shape
():
prev
=
theano
.
config
.
on_opt_error
prev
=
theano
.
config
.
on_opt_error
try
:
try
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论