Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f85b63ca
提交
f85b63ca
authored
10月 22, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
11月 16, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove stale Assert tests
These tests were covering things that don't exist anymore. params in python perform method of Ops, or misbehavior of an Op not respecting the signature
上级
3f457d07
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
19 行增加
和
50 行删除
+19
-50
basic.py
pytensor/link/numba/dispatch/basic.py
+9
-23
test_basic.py
tests/link/numba/test_basic.py
+0
-27
test_extra_ops.py
tests/link/numba/test_extra_ops.py
+10
-0
没有找到文件。
pytensor/link/numba/dispatch/basic.py
浏览文件 @
f85b63ca
...
...
@@ -233,37 +233,23 @@ def generate_fallback_impl(op, node, storage_map=None, **kwargs):
node
.
dprint
(
depth
=
5
,
print_type
=
True
)
n_outputs
=
len
(
node
.
outputs
)
single_out
=
n_outputs
==
1
if
n_outputs
>
1
:
ret_sig
=
numba
.
types
.
Tuple
([
get_numba_type
(
o
.
type
)
for
o
in
node
.
outputs
])
else
:
if
single_out
:
ret_sig
=
get_numba_type
(
node
.
outputs
[
0
]
.
type
)
output_types
=
tuple
(
out
.
type
for
out
in
node
.
outputs
)
def
py_perform
(
inputs
):
outputs
=
[[
None
]
for
i
in
range
(
n_outputs
)]
op
.
perform
(
node
,
inputs
,
outputs
)
return
outputs
if
n_outputs
==
1
:
def
py_perform_return
(
inputs
):
return
output_types
[
0
]
.
filter
(
py_perform
(
inputs
)[
0
][
0
])
else
:
ret_sig
=
numba
.
types
.
Tuple
([
get_numba_type
(
o
.
type
)
for
o
in
node
.
outputs
])
def
py_perform_return
(
inputs
):
# zip strict not specified because we are in a hot loop
return
tuple
(
out_type
.
filter
(
out
[
0
])
for
out_type
,
out
in
zip
(
output_types
,
py_perform
(
inputs
))
)
def
py_perform
(
inputs
):
output_storage
=
[[
None
]
for
_i
in
range
(
n_outputs
)]
op
.
perform
(
node
,
inputs
,
output_storage
)
outputs
=
tuple
(
o
[
0
]
for
o
in
output_storage
)
return
outputs
[
0
]
if
single_out
else
outputs
@numba_njit
def
perform
(
*
inputs
):
with
numba
.
objmode
(
ret
=
ret_sig
):
ret
=
py_perform
_return
(
inputs
)
ret
=
py_perform
(
inputs
)
return
ret
return
perform
...
...
tests/link/numba/test_basic.py
浏览文件 @
f85b63ca
...
...
@@ -26,7 +26,6 @@ from pytensor.graph.type import Type
from
pytensor.ifelse
import
ifelse
from
pytensor.link.numba.dispatch
import
basic
as
numba_basic
from
pytensor.link.numba.linker
import
NumbaLinker
from
pytensor.raise_op
import
assert_op
from
pytensor.scalar.basic
import
ScalarOp
,
as_scalar
from
pytensor.tensor.elemwise
import
Elemwise
...
...
@@ -372,32 +371,6 @@ def test_perform(inputs, op, exc):
)
def
test_perform_params
():
"""This tests for `Op.perform` implementations that require the `params` arguments."""
x
=
pt
.
vector
(
shape
=
(
2
,))
x_test_value
=
np
.
array
([
1.0
,
2.0
],
dtype
=
config
.
floatX
)
out
=
assert_op
(
x
,
np
.
array
(
True
))
compare_numba_and_py
([
x
],
out
,
[
x_test_value
])
def
test_perform_type_convert
():
"""This tests the use of `Type.filter` in `objmode`.
The `Op.perform` takes a single input that it returns as-is, but it gets a
native scalar and it's supposed to return an `np.ndarray`.
"""
x
=
pt
.
vector
()
x_test_value
=
np
.
array
([
1.0
,
2.0
],
dtype
=
config
.
floatX
)
out
=
assert_op
(
x
.
sum
(),
np
.
array
(
True
))
compare_numba_and_py
([
x
],
out
,
[
x_test_value
])
def
test_shared
():
a
=
shared
(
np
.
array
([
1
,
2
,
3
],
dtype
=
config
.
floatX
))
...
...
tests/link/numba/test_extra_ops.py
浏览文件 @
f85b63ca
...
...
@@ -5,6 +5,7 @@ import pytest
import
pytensor.tensor
as
pt
from
pytensor
import
config
from
pytensor.raise_op
import
assert_op
from
pytensor.tensor
import
extra_ops
from
tests.link.numba.test_basic
import
compare_numba_and_py
...
...
@@ -383,3 +384,12 @@ def test_Searchsorted(a, v, side, sorter, exc):
g
,
[
test_a
,
test_v
]
if
sorter
is
None
else
[
test_a
,
test_v
,
test_sorter
],
)
def
test_check_and_raise
():
x
=
pt
.
vector
()
x_test_value
=
np
.
array
([
1.0
,
2.0
],
dtype
=
config
.
floatX
)
out
=
assert_op
(
x
.
sum
(),
np
.
array
(
True
))
compare_numba_and_py
([
x
],
out
,
[
x_test_value
])
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论