Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3379fb05
提交
3379fb05
authored
8月 02, 2017
作者:
Reyhane Askari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
minor fixes
上级
ff8e99ed
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
13 行删除
+14
-13
function_module.py
theano/compile/function_module.py
+7
-7
test_function_module.py
theano/compile/tests/test_function_module.py
+7
-6
没有找到文件。
theano/compile/function_module.py
浏览文件 @
3379fb05
...
...
@@ -1007,13 +1007,13 @@ class Function(object):
return
[
i
.
variable
for
i
in
self
.
maker
.
inputs
if
i
.
implicit
]
def
sync_shared
(
self
):
for
i
,
inp
in
enumerate
(
self
.
input_storage
):
if
i
in
self
.
maker
.
fgraph
.
update_mapping
.
values
(
):
if
(
hasattr
(
theano
,
"gpuarray"
)
and
theano
.
gpuarray
.
pygpu_activated
):
import
pygpu
if
isinstance
(
inp
.
data
,
pygpu
.
gpuarray
.
GpuArray
):
inp
.
data
.
sync
()
if
(
hasattr
(
theano
,
"gpuarray"
)
and
theano
.
gpuarray
.
pygpu_activated
):
import
pygpu
for
i
,
inp
in
enumerate
(
self
.
input_storage
):
if
i
in
self
.
maker
.
fgraph
.
update_mapping
.
values
():
if
isinstance
(
inp
.
data
,
pygpu
.
gpuarray
.
GpuArray
):
inp
.
data
.
sync
()
# pickling/deepcopy support for Function
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
3379fb05
...
...
@@ -911,18 +911,17 @@ def test_empty_givens_updates():
def
test_sync
():
if
theano
.
config
.
device
==
'cuda'
and
theano
.
gpuarray
.
pygpu_activated
:
x
=
T
.
fmatrix
(
'x'
)
w
=
theano
.
shared
(
np
.
random
.
rand
(
300
,
5
00
)
.
astype
(
'float32'
),
'w'
)
b
=
theano
.
shared
(
np
.
zeros
((
5
00
))
.
astype
(
'float32'
),
'b'
)
w
=
theano
.
shared
(
np
.
random
.
rand
(
2000
,
20
00
)
.
astype
(
'float32'
),
'w'
)
b
=
theano
.
shared
(
np
.
zeros
((
20
00
))
.
astype
(
'float32'
),
'b'
)
y
=
T
.
dot
(
x
,
w
)
+
b
.
dimshuffle
(
'x'
,
0
)
y
=
T
.
dot
(
x
,
x
)
+
b
.
dimshuffle
(
'x'
,
0
)
updates
=
[(
w
,
w
+
T
.
sum
(
T
.
dot
(
x
,
w
)
+
T
.
dot
(
5
*
x
,
2
*
w
)))]
updates
=
[(
w
,
w
+
T
.
dot
(
w
,
x
)
+
T
.
dot
(
w
,
w
))]
f
=
theano
.
function
([
x
],
y
,
updates
=
updates
)
f
.
sync_shared
()
g
=
theano
.
function
([
x
],
y
,
updates
=
updates
)
x_
=
np
.
random
.
rand
(
100
,
3
00
)
.
astype
(
'float32'
)
x_
=
np
.
random
.
rand
(
2000
,
20
00
)
.
astype
(
'float32'
)
f
(
x_
)
g
(
x_
)
t_0
=
time
.
time
()
...
...
@@ -933,6 +932,8 @@ def test_sync():
g
(
x_
)
t_2
=
time
.
time
()
assert
(
t_1
-
t_0
)
>
(
t_2
-
t_1
)
else
:
raise
SkipTest
(
"Sync is only availble when device is cuda."
)
if
__name__
==
'__main__'
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论