Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bde75a2e
提交
bde75a2e
authored
3月 09, 2026
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
3月 25, 2026
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Test numba config flags directly
上级
e36afe03
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
25 行增加
和
23 行删除
+25
-23
test_basic.py
tests/link/numba/test_basic.py
+25
-23
没有找到文件。
tests/link/numba/test_basic.py
浏览文件 @
bde75a2e
...
@@ -29,6 +29,7 @@ from pytensor.link.numba.dispatch.basic import (
...
@@ -29,6 +29,7 @@ from pytensor.link.numba.dispatch.basic import (
_filter_numba_warnings
,
_filter_numba_warnings
,
cache_key_for_constant
,
cache_key_for_constant
,
numba_funcify_and_cache_key
,
numba_funcify_and_cache_key
,
numba_njit
,
)
)
from
pytensor.link.numba.linker
import
NumbaLinker
from
pytensor.link.numba.linker
import
NumbaLinker
from
pytensor.scalar.basic
import
Composite
,
ScalarOp
,
as_scalar
from
pytensor.scalar.basic
import
Composite
,
ScalarOp
,
as_scalar
...
@@ -426,14 +427,13 @@ def test_shared_updates():
...
@@ -426,14 +427,13 @@ def test_shared_updates():
def
test_config_options_fastmath
():
def
test_config_options_fastmath
():
x
=
pt
.
dvector
()
with
config
.
change_flags
(
numba__fastmath
=
True
):
with
config
.
change_flags
(
numba__fastmath
=
True
):
pytensor_numba_fn
=
function
([
x
],
pt
.
sum
(
x
),
mode
=
numba_mode
)
numba_sum_fn
=
pytensor_numba_fn
.
vm
.
jit_fn
.
py_func
.
__globals__
[
@numba_njit
"jitable_func"
def
fn_fast
(
x
):
]
.
py_func
.
__globals__
[
"impl_sum"
]
return
x
+
1
assert
numba_sum_fn
.
targetoptions
[
"fastmath"
]
==
{
assert
fn_fast
.
targetoptions
[
"fastmath"
]
==
{
"afn"
,
"afn"
,
"arcp"
,
"arcp"
,
"contract"
,
"contract"
,
...
@@ -442,28 +442,30 @@ def test_config_options_fastmath():
...
@@ -442,28 +442,30 @@ def test_config_options_fastmath():
}
}
with
config
.
change_flags
(
numba__fastmath
=
False
):
with
config
.
change_flags
(
numba__fastmath
=
False
):
pytensor_numba_fn
=
function
([
x
],
pt
.
sum
(
x
),
mode
=
numba_mode
)
numba_sum_fn
=
pytensor_numba_fn
.
vm
.
jit_fn
.
py_func
.
__globals__
[
"jitable_func"
]
.
py_func
.
__globals__
[
"impl_sum"
]
assert
numba_sum_fn
.
targetoptions
[
"fastmath"
]
is
False
@numba_njit
def
fn_nofast
(
x
):
return
x
+
1
assert
fn_nofast
.
targetoptions
[
"fastmath"
]
is
False
def
test_config_options_cached
():
x
=
pt
.
dvector
()
def
test_config_options_cached
():
with
config
.
change_flags
(
numba__cache
=
True
):
with
config
.
change_flags
(
numba__cache
=
True
):
pytensor_numba_fn
=
function
([
x
],
pt
.
sum
(
x
),
mode
=
numba_mode
)
numba_sum_fn
=
pytensor_numba_fn
.
vm
.
jit_fn
.
py_func
.
__globals__
[
@numba_njit
(
cache
=
True
)
"jitable_func"
def
fn_cached
(
x
):
]
.
py_func
.
__globals__
[
"impl_sum"
]
return
x
+
1
assert
not
isinstance
(
numba_sum_fn
.
_cache
,
numba
.
core
.
caching
.
NullCache
)
assert
not
isinstance
(
fn_cached
.
_cache
,
numba
.
core
.
caching
.
NullCache
)
with
config
.
change_flags
(
numba__cache
=
False
):
with
config
.
change_flags
(
numba__cache
=
False
):
pytensor_numba_fn
=
function
([
x
],
pt
.
sum
(
x
),
mode
=
numba_mode
)
# Without caching we don't wrap the function in jitable_func
@numba_njit
numba_sum_fn
=
pytensor_numba_fn
.
vm
.
jit_fn
.
py_func
.
__globals__
[
"impl_sum"
]
def
fn_uncached
(
x
):
assert
isinstance
(
numba_sum_fn
.
_cache
,
numba
.
core
.
caching
.
NullCache
)
return
x
+
1
assert
isinstance
(
fn_uncached
.
_cache
,
numba
.
core
.
caching
.
NullCache
)
def
test_scalar_return_value_conversion
():
def
test_scalar_return_value_conversion
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论