Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
409a4b2a
提交
409a4b2a
authored
12月 21, 2025
作者:
ricardoV94
提交者:
Ricardo Vieira
12月 21, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert accidental structured sparse changes
*Remove `structured_prefix` for Ops that map 0->0 *Do not introduce new structured ops that don't map 0->0 besides the ones that already existed
上级
5c350ab2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
41 行增加
和
90 行删除
+41
-90
math.py
pytensor/sparse/math.py
+21
-70
test_math.py
tests/sparse/test_math.py
+20
-20
没有找到文件。
pytensor/sparse/math.py
浏览文件 @
409a4b2a
...
@@ -41,7 +41,7 @@ def structured_elemwise(tensor_op):
...
@@ -41,7 +41,7 @@ def structured_elemwise(tensor_op):
@structured_elemwise
(
ptm
.
abs
)
@structured_elemwise
(
ptm
.
abs
)
def
structured_
abs
(
x
):
def
abs
(
x
):
"""
"""
Compute abs(x) for all non-zero elements of x.
Compute abs(x) for all non-zero elements of x.
"""
"""
...
@@ -61,13 +61,6 @@ def structured_exp(x):
...
@@ -61,13 +61,6 @@ def structured_exp(x):
"""
"""
@structured_elemwise
(
ptm
.
exp2
)
def
structured_exp2
(
x
):
"""
Compute exp2(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
log
)
@structured_elemwise
(
ptm
.
log
)
def
structured_log
(
x
):
def
structured_log
(
x
):
"""
"""
...
@@ -75,20 +68,6 @@ def structured_log(x):
...
@@ -75,20 +68,6 @@ def structured_log(x):
"""
"""
@structured_elemwise
(
ptm
.
log2
)
def
structured_log2
(
x
):
"""
Compute log2(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
log10
)
def
structured_log10
(
x
):
"""
Compute log10(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
pow
)
@structured_elemwise
(
ptm
.
pow
)
def
structured_pow
(
x
,
y
):
def
structured_pow
(
x
,
y
):
"""
"""
...
@@ -118,161 +97,133 @@ def structured_add(x, y):
...
@@ -118,161 +97,133 @@ def structured_add(x, y):
@structured_elemwise
(
ptm
.
sin
)
@structured_elemwise
(
ptm
.
sin
)
def
s
tructured_s
in
(
x
):
def
sin
(
x
):
"""
"""
Compute sin(x) for all non-zero elements of x.
Compute sin(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
sinh
)
@structured_elemwise
(
ptm
.
sinh
)
def
s
tructured_s
inh
(
x
):
def
sinh
(
x
):
"""
"""
Compute sinh(x) for all non-zero elements of x.
Compute sinh(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
arcsin
)
@structured_elemwise
(
ptm
.
arcsin
)
def
structured_
arcsin
(
x
):
def
arcsin
(
x
):
"""
"""
Compute arcsin(x) for all non-zero elements of x.
Compute arcsin(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
arcsinh
)
@structured_elemwise
(
ptm
.
arcsinh
)
def
structured_
arcsinh
(
x
):
def
arcsinh
(
x
):
"""
"""
Compute arcsinh(x) for all non-zero elements of x.
Compute arcsinh(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
cos
)
def
structured_cos
(
x
):
"""
Compute cos(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
cosh
)
def
structured_cosh
(
x
):
"""
Compute cosh(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
arccos
)
def
structured_arccos
(
x
):
"""
Compute arccos(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
arccosh
)
def
structured_arccosh
(
x
):
"""
Compute arccosh(x) for all non-zero elements of x.
"""
@structured_elemwise
(
ptm
.
tan
)
@structured_elemwise
(
ptm
.
tan
)
def
structured_
tan
(
x
):
def
tan
(
x
):
"""
"""
Compute tan(x) for all non-zero elements of x.
Compute tan(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
tanh
)
@structured_elemwise
(
ptm
.
tanh
)
def
structured_
tanh
(
x
):
def
tanh
(
x
):
"""
"""
Compute tanh(x) for all non-zero elements of x.
Compute tanh(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
arctan
)
@structured_elemwise
(
ptm
.
arctan
)
def
structured_
arctan
(
x
):
def
arctan
(
x
):
"""
"""
Compute arctan(x) for all non-zero elements of x.
Compute arctan(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
arctanh
)
@structured_elemwise
(
ptm
.
arctanh
)
def
structured_
arctanh
(
x
):
def
arctanh
(
x
):
"""
"""
Compute arctanh(x) for all non-zero elements of x.
Compute arctanh(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
round_half_to_even
)
@structured_elemwise
(
ptm
.
round_half_to_even
)
def
structured_
rint
(
x
):
def
rint
(
x
):
"""
"""
Compute round_half_to_even(x) for all non-zero elements of x.
Compute round_half_to_even(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
sign
)
@structured_elemwise
(
ptm
.
sign
)
def
s
tructured_s
ign
(
x
):
def
sign
(
x
):
"""
"""
Compute sign(x) for all non-zero elements of x.
Compute sign(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
ceil
)
@structured_elemwise
(
ptm
.
ceil
)
def
structured_
ceil
(
x
):
def
ceil
(
x
):
"""
"""
Compute ceil(x) for all non-zero elements of x.
Compute ceil(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
floor
)
@structured_elemwise
(
ptm
.
floor
)
def
structured_
floor
(
x
):
def
floor
(
x
):
"""
"""
Compute floor(x) for all non-zero elements of x.
Compute floor(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
log1p
)
@structured_elemwise
(
ptm
.
log1p
)
def
structured_
log1p
(
x
):
def
log1p
(
x
):
"""
"""
Compute log(1 + x) for all non-zero elements of x.
Compute log(1 + x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
expm1
)
@structured_elemwise
(
ptm
.
expm1
)
def
structured_
expm1
(
x
):
def
expm1
(
x
):
"""
"""
Compute exp(x) - 1 for all non-zero elements of x.
Compute exp(x) - 1 for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
deg2rad
)
@structured_elemwise
(
ptm
.
deg2rad
)
def
structured_
deg2rad
(
x
):
def
deg2rad
(
x
):
"""
"""
Convert degrees to radians for all non-zero elements of x.
Convert degrees to radians for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
rad2deg
)
@structured_elemwise
(
ptm
.
rad2deg
)
def
structured_
rad2deg
(
x
):
def
rad2deg
(
x
):
"""
"""
Convert radians to degrees for all non-zero elements of x.
Convert radians to degrees for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
trunc
)
@structured_elemwise
(
ptm
.
trunc
)
def
structured_
trunc
(
x
):
def
trunc
(
x
):
"""
"""
Truncate the decimal part of x for all non-zero elements of x.
Truncate the decimal part of x for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
sqr
)
@structured_elemwise
(
ptm
.
sqr
)
def
s
tructured_s
qr
(
x
):
def
sqr
(
x
):
"""
"""
Compute sqr(x) for all non-zero elements of x.
Compute sqr(x) for all non-zero elements of x.
"""
"""
@structured_elemwise
(
ptm
.
sqrt
)
@structured_elemwise
(
ptm
.
sqrt
)
def
s
tructured_s
qrt
(
x
):
def
sqrt
(
x
):
"""
"""
Compute sqrt(x) for all non-zero elements of x.
Compute sqrt(x) for all non-zero elements of x.
"""
"""
...
@@ -292,7 +243,7 @@ def conjugate(x):
...
@@ -292,7 +243,7 @@ def conjugate(x):
return
_conj
(
_x
)
return
_conj
(
_x
)
structured_conjugate
=
conjugate
structured_conjugate
=
conj
=
conj
ugate
class
SpSum
(
Op
):
class
SpSum
(
Op
):
...
...
tests/sparse/test_math.py
浏览文件 @
409a4b2a
...
@@ -1382,32 +1382,32 @@ StructuredAddTester = elemwise_checker(
...
@@ -1382,32 +1382,32 @@ StructuredAddTester = elemwise_checker(
name
=
"StructuredAddTester"
,
name
=
"StructuredAddTester"
,
)
)
SinTester
=
elemwise_checker
(
psm
.
s
tructured_s
in
,
np
.
sin
)
SinTester
=
elemwise_checker
(
psm
.
sin
,
np
.
sin
)
TanTester
=
elemwise_checker
(
psm
.
structured_
tan
,
np
.
tan
,
gap
=
(
-
1
,
1
))
TanTester
=
elemwise_checker
(
psm
.
tan
,
np
.
tan
,
gap
=
(
-
1
,
1
))
ArcsinTester
=
elemwise_checker
(
ArcsinTester
=
elemwise_checker
(
psm
.
structured_arcsin
,
np
.
arcsin
,
gap
=
(
-
1
,
1
),
gap_grad
=
(
-
0.99
,
0.99
)
psm
.
arcsinh
,
np
.
arcsin
,
gap
=
(
-
1
,
1
),
gap_grad
=
(
-
0.99
,
0.99
)
)
)
ArctanTester
=
elemwise_checker
(
psm
.
structured_
arctan
,
np
.
arctan
)
ArctanTester
=
elemwise_checker
(
psm
.
arctan
,
np
.
arctan
)
SinhTester
=
elemwise_checker
(
psm
.
s
tructured_s
inh
,
np
.
sinh
)
SinhTester
=
elemwise_checker
(
psm
.
sinh
,
np
.
sinh
)
ArcsinhTester
=
elemwise_checker
(
psm
.
structured_
arcsinh
,
np
.
arcsinh
,
gap
=
(
-
1
,
1
))
ArcsinhTester
=
elemwise_checker
(
psm
.
arcsinh
,
np
.
arcsinh
,
gap
=
(
-
1
,
1
))
TanhTester
=
elemwise_checker
(
psm
.
structured_
tanh
,
np
.
tanh
,
gap
=
(
-
1
,
1
))
TanhTester
=
elemwise_checker
(
psm
.
tanh
,
np
.
tanh
,
gap
=
(
-
1
,
1
))
ArctanhTester
=
elemwise_checker
(
ArctanhTester
=
elemwise_checker
(
psm
.
structured_
arctanh
,
np
.
arctanh
,
gap
=
(
-
0.9
,
1
),
gap_grad
=
(
-
0.9
,
0.95
)
psm
.
arctanh
,
np
.
arctanh
,
gap
=
(
-
0.9
,
1
),
gap_grad
=
(
-
0.9
,
0.95
)
)
)
RintTester
=
elemwise_checker
(
RintTester
=
elemwise_checker
(
psm
.
structured_
rint
,
np
.
rint
,
grad_test
=
False
,
test_dtypes
=
float_dtypes
psm
.
rint
,
np
.
rint
,
grad_test
=
False
,
test_dtypes
=
float_dtypes
)
)
SgnTester
=
elemwise_checker
(
SgnTester
=
elemwise_checker
(
psm
.
s
tructured_s
ign
,
psm
.
sign
,
np
.
sign
,
np
.
sign
,
grad_test
=
False
,
grad_test
=
False
,
test_dtypes
=
[
test_dtypes
=
[
...
@@ -1416,46 +1416,46 @@ SgnTester = elemwise_checker(
...
@@ -1416,46 +1416,46 @@ SgnTester = elemwise_checker(
)
)
CeilTester
=
elemwise_checker
(
CeilTester
=
elemwise_checker
(
psm
.
structured_
ceil
,
psm
.
ceil
,
np
.
ceil
,
np
.
ceil
,
grad_test
=
False
,
grad_test
=
False
,
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
)
)
FloorTester
=
elemwise_checker
(
FloorTester
=
elemwise_checker
(
psm
.
structured_
floor
,
psm
.
floor
,
np
.
floor
,
np
.
floor
,
grad_test
=
False
,
grad_test
=
False
,
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
)
)
Log1pTester
=
elemwise_checker
(
psm
.
structured_
log1p
,
np
.
log1p
,
gap
=
(
0.5
,
10
))
Log1pTester
=
elemwise_checker
(
psm
.
log1p
,
np
.
log1p
,
gap
=
(
0.5
,
10
))
Expm1Tester
=
elemwise_checker
(
psm
.
structured_
expm1
,
np
.
expm1
)
Expm1Tester
=
elemwise_checker
(
psm
.
expm1
,
np
.
expm1
)
Deg2radTester
=
elemwise_checker
(
Deg2radTester
=
elemwise_checker
(
psm
.
structured_
deg2rad
,
psm
.
deg2rad
,
np
.
deg2rad
,
np
.
deg2rad
,
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
)
)
Rad2degTester
=
elemwise_checker
(
Rad2degTester
=
elemwise_checker
(
psm
.
structured_
rad2deg
,
psm
.
rad2deg
,
np
.
rad2deg
,
np
.
rad2deg
,
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
)
)
TruncTester
=
elemwise_checker
(
TruncTester
=
elemwise_checker
(
psm
.
structured_
trunc
,
psm
.
trunc
,
np
.
trunc
,
np
.
trunc
,
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
test_dtypes
=
[
m
for
m
in
all_dtypes
if
m
not
in
complex_dtypes
],
grad_test
=
False
,
grad_test
=
False
,
)
)
SqrTester
=
elemwise_checker
(
psm
.
s
tructured_s
qr
,
lambda
x
:
x
*
x
)
SqrTester
=
elemwise_checker
(
psm
.
sqr
,
lambda
x
:
x
*
x
)
SqrtTester
=
elemwise_checker
(
psm
.
s
tructured_s
qrt
,
np
.
sqrt
,
gap
=
(
0
,
10
))
SqrtTester
=
elemwise_checker
(
psm
.
sqrt
,
np
.
sqrt
,
gap
=
(
0
,
10
))
ConjTester
=
elemwise_checker
(
psm
.
structured_
conjugate
,
np
.
conj
,
grad_test
=
False
)
ConjTester
=
elemwise_checker
(
psm
.
conjugate
,
np
.
conj
,
grad_test
=
False
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论