Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3ced044b
提交
3ced044b
authored
11月 19, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
12月 15, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tweak test tolerances
上级
856b81b9
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
20 行增加
和
13 行删除
+20
-13
test_conv.py
tests/tensor/signal/test_conv.py
+6
-5
test_basic.py
tests/tensor/test_basic.py
+2
-2
test_blockwise.py
tests/tensor/test_blockwise.py
+1
-1
test_nlinalg.py
tests/tensor/test_nlinalg.py
+10
-4
test_slinalg.py
tests/tensor/test_slinalg.py
+1
-1
没有找到文件。
tests/tensor/signal/test_conv.py
浏览文件 @
3ced044b
...
@@ -31,7 +31,7 @@ def test_convolve1d(mode, data_shape, kernel_shape):
...
@@ -31,7 +31,7 @@ def test_convolve1d(mode, data_shape, kernel_shape):
np
.
testing
.
assert_allclose
(
np
.
testing
.
assert_allclose
(
fn
(
data_val
,
kernel_val
),
fn
(
data_val
,
kernel_val
),
scipy_convolve
(
data_val
,
kernel_val
,
mode
=
mode
),
scipy_convolve
(
data_val
,
kernel_val
,
mode
=
mode
),
rtol
=
1e-6
if
config
.
floatX
==
"float32"
else
1e-1
5
,
rtol
=
1e-6
if
config
.
floatX
==
"float32"
else
1e-1
4
,
)
)
utt
.
verify_grad
(
op
=
lambda
x
:
op
(
x
,
kernel_val
),
pt
=
[
data_val
])
utt
.
verify_grad
(
op
=
lambda
x
:
op
(
x
,
kernel_val
),
pt
=
[
data_val
])
...
@@ -198,17 +198,18 @@ def test_batched_1d_agrees_with_2d_row_filter(mode, method):
...
@@ -198,17 +198,18 @@ def test_batched_1d_agrees_with_2d_row_filter(mode, method):
fn
=
function
([
data
,
kernel_1d
],
[
output_1d
,
output_2d
,
grad_1d
,
grad_2d
])
fn
=
function
([
data
,
kernel_1d
],
[
output_1d
,
output_2d
,
grad_1d
,
grad_2d
])
data_val
=
np
.
random
.
normal
(
size
=
(
10
,
8
))
.
astype
(
config
.
floatX
)
rng
=
np
.
random
.
default_rng
([
201
,
sum
(
map
(
ord
,
mode
)),
sum
(
map
(
ord
,
method
))])
kernel_1d_val
=
np
.
random
.
normal
(
size
=
(
3
,))
.
astype
(
config
.
floatX
)
data_val
=
rng
.
normal
(
size
=
(
10
,
8
))
.
astype
(
config
.
floatX
)
kernel_1d_val
=
rng
.
normal
(
size
=
(
3
,))
.
astype
(
config
.
floatX
)
forward_1d
,
forward_2d
,
backward_1d
,
backward_2d
=
fn
(
data_val
,
kernel_1d_val
)
forward_1d
,
forward_2d
,
backward_1d
,
backward_2d
=
fn
(
data_val
,
kernel_1d_val
)
np
.
testing
.
assert_allclose
(
np
.
testing
.
assert_allclose
(
forward_1d
,
forward_1d
,
forward_2d
,
forward_2d
,
rtol
=
1e-5
if
config
.
floatX
==
"float32"
else
1e-1
3
,
rtol
=
1e-5
if
config
.
floatX
==
"float32"
else
1e-1
2
,
)
)
np
.
testing
.
assert_allclose
(
np
.
testing
.
assert_allclose
(
backward_1d
,
backward_1d
,
backward_2d
,
backward_2d
,
rtol
=
1e-5
if
config
.
floatX
==
"float32"
else
1e-1
3
,
rtol
=
1e-5
if
config
.
floatX
==
"float32"
else
1e-1
2
,
)
)
tests/tensor/test_basic.py
浏览文件 @
3ced044b
...
@@ -2584,7 +2584,7 @@ class TestARange:
...
@@ -2584,7 +2584,7 @@ class TestARange:
start_v_
,
stop_v_
,
step_v_
,
dtype
=
out
.
dtype
start_v_
,
stop_v_
,
step_v_
,
dtype
=
out
.
dtype
)
)
assert
np
.
all
(
f_val
==
expected_val
)
np
.
testing
.
assert_allclose
(
f_val
,
expected_val
,
strict
=
True
,
rtol
=
3e-7
)
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"cast_policy"
,
"cast_policy"
,
...
@@ -2621,7 +2621,7 @@ class TestARange:
...
@@ -2621,7 +2621,7 @@ class TestARange:
elif
config
.
cast_policy
==
"numpy+floatX"
:
elif
config
.
cast_policy
==
"numpy+floatX"
:
expected_val
=
np
.
arange
(
start_v_
,
stop_v_
,
step_v_
)
expected_val
=
np
.
arange
(
start_v_
,
stop_v_
,
step_v_
)
assert
np
.
all
(
f_val
==
expected_val
)
np
.
testing
.
assert_allclose
(
f_val
,
expected_val
,
strict
=
True
)
@pytest.mark.parametrize
(
@pytest.mark.parametrize
(
"cast_policy"
,
"cast_policy"
,
...
...
tests/tensor/test_blockwise.py
浏览文件 @
3ced044b
...
@@ -432,7 +432,7 @@ class BlockwiseOpTester:
...
@@ -432,7 +432,7 @@ class BlockwiseOpTester:
pt_out
,
pt_out
,
np_out
,
np_out
,
rtol
=
1e-7
if
config
.
floatX
==
"float64"
else
1e-5
,
rtol
=
1e-7
if
config
.
floatX
==
"float64"
else
1e-5
,
atol
=
1e-6
if
config
.
floatX
==
"float64"
else
1e-4
,
atol
=
1e-6
if
config
.
floatX
==
"float64"
else
2e-2
,
)
)
...
...
tests/tensor/test_nlinalg.py
浏览文件 @
3ced044b
...
@@ -166,8 +166,9 @@ class TestSvd(utt.InferShapeTester):
...
@@ -166,8 +166,9 @@ class TestSvd(utt.InferShapeTester):
np_outputs
=
np_outputs
if
isinstance
(
np_outputs
,
tuple
)
else
[
np_outputs
]
np_outputs
=
np_outputs
if
isinstance
(
np_outputs
,
tuple
)
else
[
np_outputs
]
rtol
=
1e-5
if
config
.
floatX
==
"float32"
else
1e-7
for
np_val
,
pt_val
in
zip
(
np_outputs
,
pt_outputs
,
strict
=
True
):
for
np_val
,
pt_val
in
zip
(
np_outputs
,
pt_outputs
,
strict
=
True
):
assert
_allclose
(
np_val
,
pt_va
l
)
np
.
testing
.
assert_allclose
(
np_val
,
pt_val
,
rtol
=
rto
l
)
def
test_svd_infer_shape
(
self
):
def
test_svd_infer_shape
(
self
):
self
.
validate_shape
((
4
,
4
),
full_matrices
=
True
,
compute_uv
=
True
)
self
.
validate_shape
((
4
,
4
),
full_matrices
=
True
,
compute_uv
=
True
)
...
@@ -465,15 +466,20 @@ class TestEigh(TestEig):
...
@@ -465,15 +466,20 @@ class TestEigh(TestEig):
w_np
,
v_np
=
np
.
linalg
.
eigh
(
A_val
)
w_np
,
v_np
=
np
.
linalg
.
eigh
(
A_val
)
np
.
testing
.
assert_allclose
(
w
,
w_np
)
np
.
testing
.
assert_allclose
(
w
,
w_np
)
np
.
testing
.
assert_allclose
(
v
,
v_np
)
np
.
testing
.
assert_allclose
(
v
,
v_np
)
assert_array_almost_equal
(
np
.
dot
(
A_val
,
v
),
w
*
v
)
rtol
=
1e-2
if
self
.
dtype
==
"float32"
else
1e-7
np
.
testing
.
assert_allclose
(
np
.
dot
(
A_val
,
v
),
w
*
v
,
rtol
=
rtol
)
def
test_uplo
(
self
):
def
test_uplo
(
self
):
S
=
self
.
S
S
=
self
.
S
a
=
matrix
(
dtype
=
self
.
dtype
)
a
=
matrix
(
dtype
=
self
.
dtype
)
wu
,
vu
=
(
out
.
eval
({
a
:
S
})
for
out
in
self
.
op
(
a
,
"U"
))
wu
,
vu
=
(
out
.
eval
({
a
:
S
})
for
out
in
self
.
op
(
a
,
"U"
))
wl
,
vl
=
(
out
.
eval
({
a
:
S
})
for
out
in
self
.
op
(
a
,
"L"
))
wl
,
vl
=
(
out
.
eval
({
a
:
S
})
for
out
in
self
.
op
(
a
,
"L"
))
assert_array_almost_equal
(
wu
,
wl
)
atol
=
1e-14
if
np
.
dtype
(
self
.
dtype
)
.
itemsize
==
8
else
1e-5
assert_array_almost_equal
(
vu
*
np
.
sign
(
vu
[
0
,
:]),
vl
*
np
.
sign
(
vl
[
0
,
:]))
rtol
=
1e-14
if
np
.
dtype
(
self
.
dtype
)
.
itemsize
==
8
else
1e-3
np
.
testing
.
assert_allclose
(
wu
,
wl
,
atol
=
atol
,
rtol
=
rtol
)
np
.
testing
.
assert_allclose
(
vu
*
np
.
sign
(
vu
[
0
,
:]),
vl
*
np
.
sign
(
vl
[
0
,
:]),
atol
=
atol
,
rtol
=
rtol
)
def
test_grad
(
self
):
def
test_grad
(
self
):
X
=
self
.
X
X
=
self
.
X
...
...
tests/tensor/test_slinalg.py
浏览文件 @
3ced044b
...
@@ -886,7 +886,7 @@ def test_expm():
...
@@ -886,7 +886,7 @@ def test_expm():
"mode"
,
[
"symmetric"
,
"nonsymmetric_real_eig"
,
"nonsymmetric_complex_eig"
][
-
1
:]
"mode"
,
[
"symmetric"
,
"nonsymmetric_real_eig"
,
"nonsymmetric_complex_eig"
][
-
1
:]
)
)
def
test_expm_grad
(
mode
):
def
test_expm_grad
(
mode
):
rng
=
np
.
random
.
default_rng
()
rng
=
np
.
random
.
default_rng
(
[
898
,
sum
(
map
(
ord
,
mode
))]
)
match
mode
:
match
mode
:
case
"symmetric"
:
case
"symmetric"
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论