Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9a32adb3
提交
9a32adb3
authored
1月 01, 2021
作者:
Brandon T. Willard
提交者:
Brandon T. Willard
1月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Preempt missing CVM and fall back to non-C VM in VMLinker.make_vm
上级
bdb05333
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
32 行增加
和
8 行删除
+32
-8
test_vm.py
tests/link/test_vm.py
+24
-4
vm.py
theano/link/vm.py
+8
-4
没有找到文件。
tests/link/test_vm.py
浏览文件 @
9a32adb3
...
...
@@ -13,7 +13,7 @@ from theano.gof.graph import Apply
from
theano.gof.op
import
Op
from
theano.ifelse
import
ifelse
from
theano.link.c.exceptions
import
MissingGXX
from
theano.link.vm
import
VMLinker
from
theano.link.vm
import
Loop
,
VMLinker
class
TestCallbacks
:
...
...
@@ -450,19 +450,39 @@ def test_no_recycling():
assert
m1
is
m2
def
test_VMLinker_no_cxx
():
@pytest.mark.skipif
(
not
theano
.
config
.
cxx
,
reason
=
"G++ not available, so we need to skip this test."
)
def
test_VMLinker_make_vm_cvm
():
# We don't want this at module level, since CXX might not be present
from
theano.link.c.cvm
import
CVM
a
=
tensor
.
scalar
()
linker
=
VMLinker
(
allow_gc
=
False
,
use_cloop
=
True
)
f
=
function
([
a
],
a
,
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
))
assert
isinstance
(
f
.
fn
,
CVM
)
def
test_VMLinker_make_vm_no_cvm
():
from
importlib
import
reload
from
unittest.mock
import
patch
with
config
.
change_flags
(
cxx
=
""
):
# Make sure that GXX isn't present
with
pytest
.
raises
(
MissingGXX
):
import
theano.link.c.cvm
reload
(
theano
.
link
.
c
.
cvm
)
# Make sure that `cvm` module is missing
with
patch
.
dict
(
"sys.modules"
,
{
"theano.link.c.cvm"
:
None
}):
linker
=
VMLinker
(
allow_gc
=
False
,
use_cloop
=
True
)
a
=
tensor
.
scalar
()
linker
=
VMLinker
(
allow_gc
=
False
,
use_cloop
=
True
)
with
pytest
.
raises
(
ModuleNotFoundError
):
_
=
function
([
a
],
a
,
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
))
import
theano.link.c.cvm
f
=
function
([
a
],
a
,
mode
=
Mode
(
optimizer
=
None
,
linker
=
linker
))
assert
isinstance
(
f
.
fn
,
Loop
)
theano/link/vm.py
浏览文件 @
9a32adb3
...
...
@@ -13,8 +13,9 @@ import warnings
from
collections
import
defaultdict
from
theano.configdefaults
import
config
from
theano.gof
import
Constant
,
Variable
from
theano.gof
.graph
import
Constant
,
Variable
from
theano.link.basic
import
Container
,
LocalLinker
from
theano.link.c.exceptions
import
MissingGXX
from
theano.link.utils
import
gc_helper
,
map_storage
,
raise_with_op
...
...
@@ -888,6 +889,11 @@ class VMLinker(LocalLinker):
pre_call_clear
=
[
storage_map
[
v
]
for
v
in
self
.
no_recycling
]
try
:
from
theano.link.c.cvm
import
CVM
except
(
MissingGXX
,
ImportError
):
CVM
=
None
if
(
self
.
callback
is
not
None
or
self
.
callback_input
is
not
None
...
...
@@ -920,9 +926,7 @@ class VMLinker(LocalLinker):
callback
=
self
.
callback
,
callback_input
=
self
.
callback_input
,
)
elif
self
.
use_cloop
:
from
theano.link.c.cvm
import
CVM
elif
self
.
use_cloop
and
CVM
:
# create a map from nodes to ints and vars to ints
nodes_idx
=
{}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论