Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d4b8260c
提交
d4b8260c
authored
12月 01, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
12月 08, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eig impls: Keep complex outputs in Blockwise and Numba
上级
09cdd75a
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
4 行删除
+26
-4
nlinalg.py
pytensor/link/numba/dispatch/nlinalg.py
+4
-2
nlinalg.py
pytensor/tensor/nlinalg.py
+2
-1
test_blockwise.py
tests/tensor/test_blockwise.py
+20
-1
没有找到文件。
pytensor/link/numba/dispatch/nlinalg.py
浏览文件 @
d4b8260c
...
...
@@ -81,9 +81,11 @@ def numba_funcify_Eig(op, node, **kwargs):
@numba_basic.numba_njit
def
eig
(
x
):
return
np
.
linalg
.
eig
(
inputs_cast
(
x
))
w
,
v
=
np
.
linalg
.
eig
(
inputs_cast
(
x
))
return
w
.
astype
(
w_dtype
),
v
.
astype
(
w_dtype
)
return
eig
cache_version
=
1
return
eig
,
cache_version
@register_funcify_default_op_cache_key
(
Eigh
)
...
...
pytensor/tensor/nlinalg.py
浏览文件 @
d4b8260c
...
...
@@ -325,7 +325,8 @@ class Eig(Op):
"""
__props__
:
tuple
[
str
,
...
]
=
()
gufunc_spec
=
(
"numpy.linalg.eig"
,
1
,
2
)
# Can't use numpy directly in Blockwise, because of the dynamic dtype
# gufunc_spec = ("numpy.linalg.eig", 1, 2)
gufunc_signature
=
"(m,m)->(m),(m,m)"
def
make_node
(
self
,
x
):
...
...
tests/tensor/test_blockwise.py
浏览文件 @
d4b8260c
...
...
@@ -24,7 +24,7 @@ from pytensor.tensor import (
vector
,
)
from
pytensor.tensor.blockwise
import
Blockwise
,
vectorize_node_fallback
from
pytensor.tensor.nlinalg
import
MatrixInverse
from
pytensor.tensor.nlinalg
import
MatrixInverse
,
eig
from
pytensor.tensor.rewriting.blas
import
specialize_matmul_to_batched_dot
from
pytensor.tensor.signal
import
convolve1d
from
pytensor.tensor.slinalg
import
(
...
...
@@ -763,3 +763,22 @@ def test_partial_inplace():
add_supervisor_to_fgraph
(
fgraph
,
[
In
(
inp
,
mutable
=
True
)
for
inp
in
fgraph
.
inputs
])
rewrite_graph
(
fgraph
,
include
=
(
"inplace"
,))
assert
fgraph
.
outputs
[
0
]
.
owner
.
op
.
destroy_map
==
{
1
:
[
1
]}
def
test_eig_blockwise
():
x
=
tensor
(
"x"
,
shape
=
(
2
,
3
,
3
),
dtype
=
"float64"
)
eigen_values
,
eigen_vectors
=
eig
(
x
)
assert
eigen_values
.
dtype
==
"complex128"
assert
eigen_vectors
.
dtype
==
"complex128"
fn
=
function
([
x
],
[
eigen_values
,
eigen_vectors
])
eigen_values_res
,
eigen_vectors_res
=
fn
(
np
.
full
((
2
,
3
,
3
),
np
.
eye
(
3
)))
np
.
testing
.
assert_allclose
(
eigen_values_res
,
np
.
ones
((
2
,
3
),
dtype
=
"complex128"
),
strict
=
True
,
)
np
.
testing
.
assert_allclose
(
eigen_vectors_res
,
np
.
full
((
2
,
3
,
3
),
np
.
eye
(
3
),
dtype
=
"complex128"
),
strict
=
True
,
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论