Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ced9939d
提交
ced9939d
authored
11月 30, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
12月 08, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Numba linalg: Fallback to objmode with complex inputs
上级
f6986e40
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
13 行删除
+8
-13
slinalg.py
pytensor/link/numba/dispatch/slinalg.py
+8
-13
没有找到文件。
pytensor/link/numba/dispatch/slinalg.py
浏览文件 @
ced9939d
...
@@ -5,6 +5,7 @@ import numpy as np
...
@@ -5,6 +5,7 @@ import numpy as np
from
pytensor
import
config
from
pytensor
import
config
from
pytensor.link.numba.dispatch
import
basic
as
numba_basic
from
pytensor.link.numba.dispatch
import
basic
as
numba_basic
from
pytensor.link.numba.dispatch.basic
import
(
from
pytensor.link.numba.dispatch.basic
import
(
generate_fallback_impl
,
numba_funcify
,
numba_funcify
,
register_funcify_default_op_cache_key
,
register_funcify_default_op_cache_key
,
)
)
...
@@ -44,12 +45,6 @@ from pytensor.tensor.slinalg import (
...
@@ -44,12 +45,6 @@ from pytensor.tensor.slinalg import (
from
pytensor.tensor.type
import
complex_dtypes
,
integer_dtypes
from
pytensor.tensor.type
import
complex_dtypes
,
integer_dtypes
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
=
(
"Complex dtype for {op} not supported in numba mode. "
"If you need this functionality, please open an issue at: https://github.com/pymc-devs/pytensor"
)
@numba_funcify.register
(
Cholesky
)
@numba_funcify.register
(
Cholesky
)
def
numba_funcify_Cholesky
(
op
,
node
,
**
kwargs
):
def
numba_funcify_Cholesky
(
op
,
node
,
**
kwargs
):
"""
"""
...
@@ -65,7 +60,7 @@ def numba_funcify_Cholesky(op, node, **kwargs):
...
@@ -65,7 +60,7 @@ def numba_funcify_Cholesky(op, node, **kwargs):
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
if
inp_dtype
.
kind
==
"c"
:
if
inp_dtype
.
kind
==
"c"
:
r
aise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
r
eturn
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
if
discrete_inp
and
config
.
compiler_verbose
:
if
discrete_inp
and
config
.
compiler_verbose
:
print
(
"Cholesky requires casting discrete input to float"
)
# noqa: T201
print
(
"Cholesky requires casting discrete input to float"
)
# noqa: T201
...
@@ -125,7 +120,7 @@ def pivot_to_permutation(op, node, **kwargs):
...
@@ -125,7 +120,7 @@ def pivot_to_permutation(op, node, **kwargs):
def
numba_funcify_LU
(
op
,
node
,
**
kwargs
):
def
numba_funcify_LU
(
op
,
node
,
**
kwargs
):
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
if
inp_dtype
.
kind
==
"c"
:
if
inp_dtype
.
kind
==
"c"
:
r
aise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
r
eturn
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
if
discrete_inp
and
config
.
compiler_verbose
:
if
discrete_inp
and
config
.
compiler_verbose
:
print
(
"LU requires casting discrete input to float"
)
# noqa: T201
print
(
"LU requires casting discrete input to float"
)
# noqa: T201
...
@@ -192,7 +187,7 @@ def numba_funcify_LU(op, node, **kwargs):
...
@@ -192,7 +187,7 @@ def numba_funcify_LU(op, node, **kwargs):
def
numba_funcify_LUFactor
(
op
,
node
,
**
kwargs
):
def
numba_funcify_LUFactor
(
op
,
node
,
**
kwargs
):
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
inp_dtype
=
node
.
inputs
[
0
]
.
type
.
numpy_dtype
if
inp_dtype
.
kind
==
"c"
:
if
inp_dtype
.
kind
==
"c"
:
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
return
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
discrete_inp
=
inp_dtype
.
kind
in
"ibu"
if
discrete_inp
and
config
.
compiler_verbose
:
if
discrete_inp
and
config
.
compiler_verbose
:
print
(
"LUFactor requires casting discrete input to float"
)
# noqa: T201
print
(
"LUFactor requires casting discrete input to float"
)
# noqa: T201
...
@@ -252,7 +247,7 @@ def numba_funcify_Solve(op, node, **kwargs):
...
@@ -252,7 +247,7 @@ def numba_funcify_Solve(op, node, **kwargs):
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
if
A_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
if
A_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
raise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
raise
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
must_cast_A
=
A_dtype
!=
out_dtype
must_cast_A
=
A_dtype
!=
out_dtype
if
must_cast_A
and
config
.
compiler_verbose
:
if
must_cast_A
and
config
.
compiler_verbose
:
print
(
"Solve requires casting first input `A`"
)
# noqa: T201
print
(
"Solve requires casting first input `A`"
)
# noqa: T201
...
@@ -326,7 +321,7 @@ def numba_funcify_SolveTriangular(op, node, **kwargs):
...
@@ -326,7 +321,7 @@ def numba_funcify_SolveTriangular(op, node, **kwargs):
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
if
A_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
if
A_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
raise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
raise
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
must_cast_A
=
A_dtype
!=
out_dtype
must_cast_A
=
A_dtype
!=
out_dtype
if
must_cast_A
and
config
.
compiler_verbose
:
if
must_cast_A
and
config
.
compiler_verbose
:
print
(
"SolveTriangular requires casting first input `A`"
)
# noqa: T201
print
(
"SolveTriangular requires casting first input `A`"
)
# noqa: T201
...
@@ -377,7 +372,7 @@ def numba_funcify_CholeskySolve(op, node, **kwargs):
...
@@ -377,7 +372,7 @@ def numba_funcify_CholeskySolve(op, node, **kwargs):
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
out_dtype
=
node
.
outputs
[
0
]
.
type
.
numpy_dtype
if
c_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
if
c_dtype
.
kind
==
"c"
or
b_dtype
.
kind
==
"c"
:
raise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
raise
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
must_cast_c
=
c_dtype
!=
out_dtype
must_cast_c
=
c_dtype
!=
out_dtype
if
must_cast_c
and
config
.
compiler_verbose
:
if
must_cast_c
and
config
.
compiler_verbose
:
print
(
"CholeskySolve requires casting first input `c`"
)
# noqa: T201
print
(
"CholeskySolve requires casting first input `c`"
)
# noqa: T201
...
@@ -425,7 +420,7 @@ def numba_funcify_QR(op, node, **kwargs):
...
@@ -425,7 +420,7 @@ def numba_funcify_QR(op, node, **kwargs):
dtype
=
node
.
inputs
[
0
]
.
dtype
dtype
=
node
.
inputs
[
0
]
.
dtype
if
dtype
in
complex_dtypes
:
if
dtype
in
complex_dtypes
:
r
aise
NotImplementedError
(
_COMPLEX_DTYPE_NOT_SUPPORTED_MSG
.
format
(
op
=
op
)
)
r
eturn
generate_fallback_impl
(
op
,
node
=
node
,
**
kwargs
)
integer_input
=
dtype
in
integer_dtypes
integer_input
=
dtype
in
integer_dtypes
in_dtype
=
config
.
floatX
if
integer_input
else
dtype
in_dtype
=
config
.
floatX
if
integer_input
else
dtype
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论