Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e5b58faf
提交
e5b58faf
authored
6月 16, 2015
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
By default FAST_COMPILE do lazy evaluation
上级
d9fc9d73
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
27 行增加
和
2 行删除
+27
-2
mode.py
theano/compile/mode.py
+3
-1
test_vm.py
theano/gof/tests/test_vm.py
+18
-0
vm.py
theano/gof/vm.py
+6
-1
没有找到文件。
theano/compile/mode.py
浏览文件 @
e5b58faf
...
...
@@ -323,7 +323,9 @@ class Mode(object):
# If a string is passed as the mode argument in function or
# FunctionMaker, the Mode will be taken from this dictionary using the
# string as the key
FAST_COMPILE
=
Mode
(
'py'
,
'fast_compile'
)
# Use VM_linker to allow lazy evaluation by default.
FAST_COMPILE
=
Mode
(
theano
.
gof
.
vm
.
VM_Linker
(
use_cloop
=
False
,
c_thunks
=
False
),
'fast_compile'
)
if
theano
.
config
.
cxx
:
FAST_RUN
=
Mode
(
'cvm'
,
'fast_run'
)
else
:
...
...
theano/gof/tests/test_vm.py
浏览文件 @
e5b58faf
...
...
@@ -53,6 +53,24 @@ class TestCallbacks(unittest.TestCase):
assert
self
.
n_callbacks
[
'IfElse'
]
==
2
def
test_c_thunks
():
a
=
tensor
.
scalars
(
'a'
)
b
,
c
=
tensor
.
vectors
(
'bc'
)
cases
=
[
False
]
if
theano
.
config
.
cxx
:
cases
.
append
(
True
)
for
c_thunks
in
cases
:
f
=
function
([
a
,
b
,
c
],
ifelse
(
a
,
a
*
b
,
b
*
c
),
mode
=
Mode
(
optimizer
=
None
,
linker
=
vm
.
VM_Linker
(
c_thunks
=
c_thunks
,
use_cloop
=
False
)))
f
(
1
,
[
2
],
[
3
,
2
])
from
nose.tools
import
assert_raises
assert_raises
(
ValueError
,
f
,
0
,
[
2
],
[
3
,
4
])
assert
any
([
hasattr
(
t
,
'cthunk'
)
for
t
in
f
.
fn
.
thunks
])
==
c_thunks
def
test_speed
():
if
not
theano
.
config
.
cxx
:
raise
SkipTest
(
"G++ not available, so we need to skip this test."
)
...
...
theano/gof/vm.py
浏览文件 @
e5b58faf
...
...
@@ -686,7 +686,7 @@ class VM_Linker(link.LocalLinker):
"""
def
__init__
(
self
,
allow_gc
=
None
,
use_cloop
=
False
,
callback
=
None
,
lazy
=
None
,
schedule
=
None
):
lazy
=
None
,
schedule
=
None
,
c_thunks
=
None
):
"""
allow_gc - force the virtual machine to clean up unnecessary
references, in order to allow garbage collection on
...
...
@@ -705,6 +705,8 @@ class VM_Linker(link.LocalLinker):
version. If lazy is True or False, we force the version used
between Loop/LoopGC and Stack.
c_thunks - If None or True, don't change the default. If False,
don't compile c code for the thunks.
"""
# Note: if more parameters are added to __init__, make sure to forward
# them in the "type(self)(...)" call in the "accept" method below.
...
...
@@ -715,6 +717,7 @@ class VM_Linker(link.LocalLinker):
self
.
use_cloop
=
use_cloop
self
.
callback
=
callback
self
.
lazy
=
lazy
self
.
c_thunks
=
c_thunks
self
.
updated_vars
=
{}
if
schedule
:
self
.
schedule
=
schedule
...
...
@@ -1010,6 +1013,8 @@ class VM_Linker(link.LocalLinker):
for
node
in
order
:
try
:
if
self
.
c_thunks
is
False
:
node
.
op
.
_op_use_c_code
=
False
thunks
.
append
(
node
.
op
.
make_thunk
(
node
,
storage_map
,
compute_map
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论