Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
61380247
提交
61380247
authored
12月 01, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
12月 08, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Numba Cholesky: Allow inplace on C_contiguous inputs
上级
ced9939d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
19 行增加
和
9 行删除
+19
-9
cholesky.py
...nsor/link/numba/dispatch/linalg/decomposition/cholesky.py
+17
-7
test_slinalg.py
tests/link/numba/test_slinalg.py
+2
-2
没有找到文件。
pytensor/link/numba/dispatch/linalg/decomposition/cholesky.py
浏览文件 @
61380247
...
@@ -29,21 +29,27 @@ def cholesky_impl(A, lower=0, overwrite_a=False, check_finite=True):
...
@@ -29,21 +29,27 @@ def cholesky_impl(A, lower=0, overwrite_a=False, check_finite=True):
numba_potrf
=
_LAPACK
()
.
numba_xpotrf
(
dtype
)
numba_potrf
=
_LAPACK
()
.
numba_xpotrf
(
dtype
)
def
impl
(
A
,
lower
=
0
,
overwrite_a
=
False
,
check_finite
=
True
):
def
impl
(
A
,
lower
=
False
,
overwrite_a
=
False
,
check_finite
=
True
):
_N
=
np
.
int32
(
A
.
shape
[
-
1
])
_N
=
np
.
int32
(
A
.
shape
[
-
1
])
if
A
.
shape
[
-
2
]
!=
_N
:
if
A
.
shape
[
-
2
]
!=
_N
:
raise
linalg
.
LinAlgError
(
"Last 2 dimensions of A must be square"
)
raise
linalg
.
LinAlgError
(
"Last 2 dimensions of A must be square"
)
UPLO
=
val_to_int_ptr
(
ord
(
"L"
)
if
lower
else
ord
(
"U"
))
transposed
=
False
N
=
val_to_int_ptr
(
_N
)
LDA
=
val_to_int_ptr
(
_N
)
INFO
=
val_to_int_ptr
(
0
)
if
overwrite_a
and
A
.
flags
.
f_contiguous
:
if
overwrite_a
and
A
.
flags
.
f_contiguous
:
A_copy
=
A
A_copy
=
A
elif
overwrite_a
and
A
.
flags
.
c_contiguous
:
# We can work on the transpose of A directly
A_copy
=
A
.
T
transposed
=
True
lower
=
not
lower
else
:
else
:
A_copy
=
_copy_to_fortran_order
(
A
)
A_copy
=
_copy_to_fortran_order
(
A
)
UPLO
=
val_to_int_ptr
(
ord
(
"L"
)
if
lower
else
ord
(
"U"
))
N
=
val_to_int_ptr
(
_N
)
LDA
=
val_to_int_ptr
(
_N
)
INFO
=
val_to_int_ptr
(
0
)
numba_potrf
(
numba_potrf
(
UPLO
,
UPLO
,
N
,
N
,
...
@@ -61,6 +67,10 @@ def cholesky_impl(A, lower=0, overwrite_a=False, check_finite=True):
...
@@ -61,6 +67,10 @@ def cholesky_impl(A, lower=0, overwrite_a=False, check_finite=True):
for
i
in
range
(
j
+
1
,
_N
):
for
i
in
range
(
j
+
1
,
_N
):
A_copy
[
i
,
j
]
=
0.0
A_copy
[
i
,
j
]
=
0.0
return
A_copy
,
int_ptr_to_val
(
INFO
)
info_int
=
int_ptr_to_val
(
INFO
)
if
transposed
:
return
A_copy
.
T
,
info_int
return
A_copy
,
info_int
return
impl
return
impl
tests/link/numba/test_slinalg.py
浏览文件 @
61380247
...
@@ -551,8 +551,8 @@ class TestDecompositions:
...
@@ -551,8 +551,8 @@ class TestDecompositions:
val_c_contig
=
np
.
copy
(
val
,
order
=
"C"
)
val_c_contig
=
np
.
copy
(
val
,
order
=
"C"
)
res_c_contig
=
fn
(
val_c_contig
)
res_c_contig
=
fn
(
val_c_contig
)
np
.
testing
.
assert_allclose
(
res_c_contig
,
res
)
np
.
testing
.
assert_allclose
(
res_c_contig
,
res
)
#
Cannot destroy C-contiguous input
#
Should always be destroyable
np
.
testing
.
assert_allclose
(
val_c_contig
,
val
)
assert
(
val
==
val_c_contig
)
.
all
()
==
(
not
overwrite_a
)
# Test non-contiguous input
# Test non-contiguous input
val_not_contig
=
np
.
repeat
(
val
,
2
,
axis
=
0
)[::
2
]
val_not_contig
=
np
.
repeat
(
val
,
2
,
axis
=
0
)[::
2
]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论