Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
99f646ce
提交
99f646ce
authored
11月 28, 2020
作者:
Michael Osthege
提交者:
Brandon T. Willard
12月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove dependency on theano.Mode in theano.configdefaults
上级
92155d4d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
10 行删除
+29
-10
test_config.py
tests/test_config.py
+17
-0
configdefaults.py
theano/configdefaults.py
+12
-10
没有找到文件。
tests/test_config.py
浏览文件 @
99f646ce
...
@@ -121,3 +121,20 @@ class TestConfigTypes:
...
@@ -121,3 +121,20 @@ class TestConfigTypes:
with
pytest
.
raises
(
ValueError
,
match
=
"Invalid value"
):
with
pytest
.
raises
(
ValueError
,
match
=
"Invalid value"
):
cp
.
_apply
(
"notadevice"
)
cp
.
_apply
(
"notadevice"
)
assert
str
(
cp
)
==
"None (cpu, opencl*, cuda*) "
assert
str
(
cp
)
==
"None (cpu, opencl*, cuda*) "
def
test_mode_apply
():
from
theano
import
configdefaults
assert
configdefaults
.
filter_mode
(
"DebugMode"
)
==
"DebugMode"
with
pytest
.
raises
(
ValueError
,
match
=
"Expected one of"
):
configdefaults
.
filter_mode
(
"not_a_mode"
)
# test with theano.Mode instance
import
theano.compile.mode
assert
(
configdefaults
.
filter_mode
(
theano
.
compile
.
mode
.
FAST_COMPILE
)
==
theano
.
compile
.
mode
.
FAST_COMPILE
)
theano/configdefaults.py
浏览文件 @
99f646ce
...
@@ -465,7 +465,7 @@ AddConfigVar(
...
@@ -465,7 +465,7 @@ AddConfigVar(
# Also, please be careful not to modify the first item in the enum when adding
# Also, please be careful not to modify the first item in the enum when adding
# new modes, since it is the default mode.
# new modes, since it is the default mode.
def
filter_mode
(
val
):
def
filter_mode
(
val
):
if
val
in
[
str_options
=
[
"Mode"
,
"Mode"
,
"DebugMode"
,
"DebugMode"
,
"FAST_RUN"
,
"FAST_RUN"
,
...
@@ -473,18 +473,20 @@ def filter_mode(val):
...
@@ -473,18 +473,20 @@ def filter_mode(val):
"FAST_COMPILE"
,
"FAST_COMPILE"
,
"DEBUG_MODE"
,
"DEBUG_MODE"
,
"JAX"
,
"JAX"
,
]:
]
if
val
in
str_options
:
return
val
return
val
# This can be executed before Theano is completly imported, so
# This can be executed before Theano is completly imported, so
# theano.Mode is not always available.
# theano.Mode is not always available.
elif
hasattr
(
theano
,
"Mode"
)
and
isinstance
(
val
,
theano
.
Mode
):
# Instead of isinstance(val, theano.Mode),
return
val
# we can inspect the __mro__ of the object!
else
:
for
type_
in
type
(
val
)
.
__mro__
:
raise
ValueError
(
if
"theano.compile.mode.Mode"
in
str
(
type_
):
"Expected one of those string 'Mode', 'DebugMode',"
return
val
" 'FAST_RUN', 'NanGuardMode', 'FAST_COMPILE',"
raise
ValueError
(
" 'DEBUG_MODE' or an instance of Mode."
f
"Expected one of {str_options}, or an instance of theano.Mode. "
)
f
"Instead got: {val}."
)
AddConfigVar
(
AddConfigVar
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论