Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5c350ab2
提交
5c350ab2
authored
12月 21, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
12月 21, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix ordering bug between untraced_sit_sot and nit_sot
Internally Scan places those outputs to the right of nit_sot. Helper function reordering to match user definition was not handling this correctly
上级
65cc349a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
48 行增加
和
2 行删除
+48
-2
basic.py
pytensor/scan/basic.py
+2
-2
test_basic.py
tests/scan/test_basic.py
+46
-0
没有找到文件。
pytensor/scan/basic.py
浏览文件 @
5c350ab2
...
...
@@ -661,7 +661,7 @@ def scan(
else
:
actual_n_steps
=
pt
.
as_tensor
(
n_steps
,
dtype
=
"int64"
,
ndim
=
0
)
# Since we've added all sequences now we need to level them
up
based on
# Since we've added all sequences now we need to level them
off
based on
# n_steps or their different shapes
scan_seqs
=
[
seq
[:
actual_n_steps
]
for
seq
in
scan_seqs
]
...
...
@@ -1212,8 +1212,8 @@ def scan(
rightOrder
=
(
mit_sot_rightOrder
+
sit_sot_rightOrder
+
untraced_sit_sot_rightOrder
+
nit_sot_rightOrder
+
untraced_sit_sot_rightOrder
)
scan_out_list
=
[
None
]
*
len
(
rightOrder
)
for
idx
,
pos
in
enumerate
(
rightOrder
):
...
...
tests/scan/test_basic.py
浏览文件 @
5c350ab2
...
...
@@ -4470,3 +4470,49 @@ class ScanCompatibilityTests:
f_infershape
=
function
([
seq
,
init
],
out_seq_tm4
[
1
]
.
shape
)
scan_nodes_infershape
=
scan_nodes_from_fct
(
f_infershape
)
assert
len
(
scan_nodes_infershape
)
==
0
@pytest.mark.parametrize
(
"single_step"
,
(
True
,
False
))
def
test_scan_mapped_and_non_traced_output_ordering
(
single_step
):
# Regression test for https://github.com/pymc-devs/pytensor/issues/1796
rng
=
random_generator_type
(
"rng"
)
def
x_then_rng
(
rng
):
next_rng
,
x
=
pt
.
random
.
normal
(
rng
=
rng
)
.
owner
.
outputs
return
x
,
next_rng
xs
,
final_rng
=
scan
(
fn
=
x_then_rng
,
outputs_info
=
[
None
,
rng
],
n_steps
=
1
if
single_step
else
5
,
return_updates
=
False
,
)
assert
isinstance
(
xs
.
type
,
TensorType
)
assert
isinstance
(
final_rng
.
type
,
RandomGeneratorType
)
def
rng_then_x
(
rng
):
x
,
next_rng
=
x_then_rng
(
rng
)
return
next_rng
,
x
final_rng
,
xs
=
scan
(
fn
=
rng_then_x
,
outputs_info
=
[
rng
,
None
],
n_steps
=
1
if
single_step
else
5
,
return_updates
=
False
,
)
assert
isinstance
(
xs
.
type
,
TensorType
)
assert
isinstance
(
final_rng
.
type
,
RandomGeneratorType
)
def
rng_between_xs
(
rng
):
x
,
next_rng
=
x_then_rng
(
rng
)
return
x
,
next_rng
,
x
+
1
,
x
+
2
xs1
,
final_rng
,
xs2
,
xs3
=
scan
(
fn
=
rng_between_xs
,
outputs_info
=
[
None
,
rng
,
None
,
None
],
n_steps
=
1
if
single_step
else
5
,
return_updates
=
False
,
)
assert
all
(
isinstance
(
xs
.
type
,
TensorType
)
for
xs
in
(
xs1
,
xs2
,
xs3
))
assert
isinstance
(
final_rng
.
type
,
RandomGeneratorType
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论