Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d92c3675
提交
d92c3675
authored
6月 11, 2024
作者:
Adrian Seyboldt
提交者:
Ricardo Vieira
6月 11, 2024
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(numba): cholesky did not set off-diag entries to zero
上级
75a9fd2a
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
29 行增加
和
20 行删除
+29
-20
slinalg.py
pytensor/link/numba/dispatch/slinalg.py
+14
-2
test_slinalg.py
tests/link/numba/test_slinalg.py
+15
-18
没有找到文件。
pytensor/link/numba/dispatch/slinalg.py
浏览文件 @
d92c3675
...
...
@@ -310,8 +310,11 @@ def numba_funcify_SolveTriangular(op, node, **kwargs):
def
_cholesky
(
a
,
lower
=
False
,
overwrite_a
=
False
,
check_finite
=
True
):
return
linalg
.
cholesky
(
a
,
lower
=
lower
,
overwrite_a
=
overwrite_a
,
check_finite
=
check_finite
return
(
linalg
.
cholesky
(
a
,
lower
=
lower
,
overwrite_a
=
overwrite_a
,
check_finite
=
check_finite
),
0
,
)
...
...
@@ -346,6 +349,15 @@ def cholesky_impl(A, lower=0, overwrite_a=False, check_finite=True):
INFO
,
)
if
lower
:
for
j
in
range
(
1
,
_N
):
for
i
in
range
(
j
):
A_copy
[
i
,
j
]
=
0.0
else
:
for
j
in
range
(
_N
):
for
i
in
range
(
j
+
1
,
_N
):
A_copy
[
i
,
j
]
=
0.0
return
A_copy
,
int_ptr_to_val
(
INFO
)
return
impl
...
...
tests/link/numba/test_slinalg.py
浏览文件 @
d92c3675
...
...
@@ -6,10 +6,8 @@ import pytest
import
pytensor
import
pytensor.tensor
as
pt
from
pytensor
import
config
from
pytensor.compile
import
SharedVariable
from
pytensor.graph
import
Constant
,
FunctionGraph
from
pytensor.graph
import
FunctionGraph
from
tests.link.numba.test_basic
import
compare_numba_and_py
from
tests.tensor.test_extra_ops
import
set_test_value
numba
=
pytest
.
importorskip
(
"numba"
)
...
...
@@ -109,23 +107,22 @@ def test_solve_triangular_raises_on_nan_inf(value):
@pytest.mark.parametrize
(
"lower"
,
[
True
,
False
],
ids
=
[
"lower=True"
,
"lower=False"
])
def
test_numba_Cholesky
(
lower
):
x
=
set_test_value
(
pt
.
tensor
(
dtype
=
config
.
floatX
,
shape
=
(
3
,
3
)),
(
lambda
x
:
x
.
T
.
dot
(
x
))(
rng
.
random
(
size
=
(
3
,
3
))
.
astype
(
config
.
floatX
)),
)
@pytest.mark.parametrize
(
"trans"
,
[
True
,
False
],
ids
=
[
"trans=True"
,
"trans=False"
])
def
test_numba_Cholesky
(
lower
,
trans
):
cov
=
pt
.
matrix
(
"cov"
)
g
=
pt
.
linalg
.
cholesky
(
x
,
lower
=
lower
)
g_fg
=
FunctionGraph
(
outputs
=
[
g
])
if
trans
:
cov_
=
cov
.
T
else
:
cov_
=
cov
chol
=
pt
.
linalg
.
cholesky
(
cov_
,
lower
=
lower
)
compare_numba_and_py
(
g_fg
,
[
i
.
tag
.
test_value
for
i
in
g_fg
.
inputs
if
not
isinstance
(
i
,
SharedVariable
|
Constant
)
],
)
fg
=
FunctionGraph
(
outputs
=
[
chol
])
x
=
np
.
array
([
0.1
,
0.2
,
0.3
])
val
=
np
.
eye
(
3
)
+
x
[
None
,
:]
*
x
[:,
None
]
compare_numba_and_py
(
fg
,
[
val
])
def
test_numba_Cholesky_raises_on_nan_input
():
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论