Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7a0175af
提交
7a0175af
authored
7月 19, 2024
作者:
Virgile Andreani
提交者:
Virgile Andreani
7月 23, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Simplify _ChangeFlagDecorator
上级
158a7d01
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
6 行增加
和
10 行删除
+6
-10
configparser.py
pytensor/configparser.py
+3
-7
test_type.py
tests/link/c/test_type.py
+1
-1
test_blas.py
tests/tensor/test_blas.py
+1
-1
test_config.py
tests/test_config.py
+1
-1
没有找到文件。
pytensor/configparser.py
浏览文件 @
7a0175af
...
...
@@ -32,11 +32,7 @@ class ConfigAccessViolation(AttributeError):
class
_ChangeFlagsDecorator
:
def
__init__
(
self
,
*
args
,
_root
=
None
,
**
kwargs
):
# the old API supported passing a dict as the first argument:
if
args
:
assert
len
(
args
)
==
1
and
isinstance
(
args
[
0
],
dict
)
kwargs
=
dict
(
**
args
[
0
],
**
kwargs
)
def
__init__
(
self
,
_root
=
None
,
**
kwargs
):
self
.
confs
=
{
k
:
_root
.
_config_var_dict
[
k
]
for
k
in
kwargs
}
self
.
new_vals
=
kwargs
self
.
_root
=
_root
...
...
@@ -310,14 +306,14 @@ class PyTensorConfigParser:
except
(
NoOptionError
,
NoSectionError
):
raise
KeyError
(
key
)
def
change_flags
(
self
,
*
args
,
*
*
kwargs
)
->
_ChangeFlagsDecorator
:
def
change_flags
(
self
,
**
kwargs
)
->
_ChangeFlagsDecorator
:
"""
Use this as a decorator or context manager to change the value of
PyTensor config variables.
Useful during tests.
"""
return
_ChangeFlagsDecorator
(
*
args
,
_root
=
self
,
**
kwargs
)
return
_ChangeFlagsDecorator
(
_root
=
self
,
**
kwargs
)
def
warn_unused_flags
(
self
):
for
key
in
self
.
_flags_dict
:
...
...
tests/link/c/test_type.py
浏览文件 @
7a0175af
...
...
@@ -287,6 +287,6 @@ class TestEnumTypes:
assert
val_billion
==
val_million
*
1000
assert
val_two_billions
==
val_billion
*
2
@pytensor.config.change_flags
(
**
{
"cmodule__debug"
:
True
}
)
@pytensor.config.change_flags
(
cmodule__debug
=
True
)
def
test_op_with_cenumtype_debug
(
self
):
self
.
test_op_with_cenumtype
()
tests/tensor/test_blas.py
浏览文件 @
7a0175af
...
...
@@ -514,7 +514,7 @@ class TestGemmNoFlags:
C
=
self
.
get_value
(
C
,
transpose_C
,
slice_C
)
return
alpha
*
np
.
dot
(
A
,
B
)
+
beta
*
C
@config.change_flags
(
{
"blas__ldflags"
:
""
}
)
@config.change_flags
(
blas__ldflags
=
""
)
def
run_gemm
(
self
,
dtype
,
...
...
tests/test_config.py
浏览文件 @
7a0175af
...
...
@@ -168,7 +168,7 @@ def test_config_context():
with
root
.
change_flags
(
test__config_context
=
"new_value"
):
assert
root
.
test__config_context
==
"new_value"
with
root
.
change_flags
(
{
"test__config_context"
:
"new_value2"
}
):
with
root
.
change_flags
(
test__config_context
=
"new_value2"
):
assert
root
.
test__config_context
==
"new_value2"
assert
root
.
test__config_context
==
"new_value"
assert
root
.
test__config_context
==
"test_default"
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论