Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ac6dc81b
提交
ac6dc81b
authored
1月 11, 2026
作者:
ricardoV94
提交者:
Jesse Grabowski
1月 11, 2026
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Group local_block_diag_dot_to_dot_block_diag tests
上级
e75bbb2c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
14 行删除
+18
-14
test_math.py
tests/tensor/rewriting/test_math.py
+18
-14
没有找到文件。
tests/tensor/rewriting/test_math.py
浏览文件 @
ac6dc81b
...
@@ -4857,16 +4857,15 @@ def test_local_dot_to_mul_unspecified_length_1():
...
@@ -4857,16 +4857,15 @@ def test_local_dot_to_mul_unspecified_length_1():
)
)
@pytest.mark.parametrize
(
"left_multiply"
,
[
True
,
False
],
ids
=
[
"left"
,
"right"
])
class
TestBlockDiagDotToDotBlockDiag
:
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"left_multiply"
,
[
True
,
False
],
ids
=
[
"left"
,
"right"
])
@pytest.mark.parametrize
(
"batch_blockdiag"
,
[
True
,
False
],
ids
=
[
"batch_blockdiag"
,
"unbatched_blockdiag"
]
"batch_blockdiag"
,
[
True
,
False
],
ids
=
[
"batch_blockdiag"
,
"unbatched_blockdiag"
]
)
)
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"batch_other"
,
[
True
,
False
],
ids
=
[
"batched_other"
,
"unbatched_other"
]
"batch_other"
,
[
True
,
False
],
ids
=
[
"batched_other"
,
"unbatched_other"
]
)
)
def
test_local_block_diag_dot_to_dot_block_diag
(
def
test_rewrite_applies
(
self
,
left_multiply
,
batch_blockdiag
,
batch_other
):
left_multiply
,
batch_blockdiag
,
batch_other
):
"""
"""
Test that dot(block_diag(x, y,), z) is rewritten to concat(dot(x, z[:n]), dot(y, z[n:]))
Test that dot(block_diag(x, y,), z) is rewritten to concat(dot(x, z[:n]), dot(y, z[n:]))
"""
"""
...
@@ -4905,7 +4904,10 @@ def test_local_block_diag_dot_to_dot_block_diag(
...
@@ -4905,7 +4904,10 @@ def test_local_block_diag_dot_to_dot_block_diag(
n_dots_rewrite
=
sum
(
n_dots_rewrite
=
sum
(
isinstance
(
node
.
op
,
Dot
|
Dot22
)
isinstance
(
node
.
op
,
Dot
|
Dot22
)
or
(
isinstance
(
node
.
op
,
Blockwise
)
and
isinstance
(
node
.
op
.
core_op
,
Dot
|
Dot22
))
or
(
isinstance
(
node
.
op
,
Blockwise
)
and
isinstance
(
node
.
op
.
core_op
,
Dot
|
Dot22
)
)
for
node
in
fn
.
maker
.
fgraph
.
apply_nodes
for
node
in
fn
.
maker
.
fgraph
.
apply_nodes
)
)
assert
n_dots_rewrite
==
3
assert
n_dots_rewrite
==
3
...
@@ -4919,7 +4921,10 @@ def test_local_block_diag_dot_to_dot_block_diag(
...
@@ -4919,7 +4921,10 @@ def test_local_block_diag_dot_to_dot_block_diag(
n_dots_no_rewrite
=
sum
(
n_dots_no_rewrite
=
sum
(
isinstance
(
node
.
op
,
Dot
|
Dot22
)
isinstance
(
node
.
op
,
Dot
|
Dot22
)
or
(
isinstance
(
node
.
op
,
Blockwise
)
and
isinstance
(
node
.
op
.
core_op
,
Dot
|
Dot22
))
or
(
isinstance
(
node
.
op
,
Blockwise
)
and
isinstance
(
node
.
op
.
core_op
,
Dot
|
Dot22
)
)
for
node
in
fn_expected
.
maker
.
fgraph
.
apply_nodes
for
node
in
fn_expected
.
maker
.
fgraph
.
apply_nodes
)
)
assert
n_dots_no_rewrite
==
1
assert
n_dots_no_rewrite
==
1
...
@@ -4939,10 +4944,9 @@ def test_local_block_diag_dot_to_dot_block_diag(
...
@@ -4939,10 +4944,9 @@ def test_local_block_diag_dot_to_dot_block_diag(
rtol
=
1e-6
if
config
.
floatX
==
"float32"
else
1e-12
,
rtol
=
1e-6
if
config
.
floatX
==
"float32"
else
1e-12
,
)
)
@pytest.mark.parametrize
(
"rewrite"
,
[
True
,
False
],
ids
=
[
"rewrite"
,
"no_rewrite"
])
@pytest.mark.parametrize
(
"rewrite"
,
[
True
,
False
],
ids
=
[
"rewrite"
,
"no_rewrite"
])
@pytest.mark.parametrize
(
"size"
,
[
10
,
100
,
1000
],
ids
=
[
"small"
,
"medium"
,
"large"
])
@pytest.mark.parametrize
(
"size"
,
[
10
,
100
,
1000
],
ids
=
[
"small"
,
"medium"
,
"large"
])
def
test_benchmark
(
self
,
benchmark
,
size
,
rewrite
):
def
test_block_diag_dot_to_dot_concat_benchmark
(
benchmark
,
size
,
rewrite
):
rng
=
np
.
random
.
default_rng
()
rng
=
np
.
random
.
default_rng
()
a_size
=
int
(
rng
.
uniform
(
1
,
int
(
0.8
*
size
)))
a_size
=
int
(
rng
.
uniform
(
1
,
int
(
0.8
*
size
)))
b_size
=
int
(
rng
.
uniform
(
1
,
int
(
0.8
*
(
size
-
a_size
))))
b_size
=
int
(
rng
.
uniform
(
1
,
int
(
0.8
*
(
size
-
a_size
))))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论