Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
d11b5068
Unverified
Commit
d11b5068
authored
Feb 21, 2024
by
Titus
Committed by
GitHub
Feb 21, 2024
Browse files
tests: fix all_close to respect max 2 positional args (#1074)
parent
0bf71989
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
tests/test_functional.py
tests/test_functional.py
+2
-2
tests/test_modules.py
tests/test_modules.py
+2
-2
tests/test_optim.py
tests/test_optim.py
+2
-2
No files found.
tests/test_functional.py
View file @
d11b5068
...
...
@@ -26,12 +26,12 @@ k = 20
def
assert_all_approx_close
(
a
,
b
,
rtol
=
1e-3
,
atol
=
1e-3
,
count
=
0
,
throw
=
True
):
idx
=
torch
.
isclose
(
a
,
b
,
rtol
,
atol
)
idx
=
torch
.
isclose
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
sumval
=
(
idx
==
0
).
sum
().
item
()
if
sumval
>
count
:
if
throw
:
print
(
f
"Too many values not close: assert
{
sumval
}
<
{
count
}
"
)
torch
.
testing
.
assert_close
(
a
,
b
,
rtol
,
atol
)
torch
.
testing
.
assert_close
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
return
sumval
...
...
tests/test_modules.py
View file @
d11b5068
...
...
@@ -42,11 +42,11 @@ def get_args():
def
assert_all_approx_close
(
a
,
b
,
atol
=
1e-8
,
rtol
=
1e-5
,
count
=
10
):
idx
=
torch
.
isclose
(
a
,
b
,
rtol
,
atol
)
idx
=
torch
.
isclose
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
sumval
=
(
idx
==
0
).
sum
().
item
()
if
sumval
>
count
:
print
(
f
"Too many values not close: assert
{
sumval
}
<
{
count
}
"
)
torch
.
testing
.
assert_close
(
a
,
b
,
rtol
,
atol
)
torch
.
testing
.
assert_close
(
a
,
b
,
rtol
=
rtol
,
atol
=
atol
)
class
LinearFunction
(
torch
.
autograd
.
Function
):
...
...
tests/test_optim.py
View file @
d11b5068
...
...
@@ -145,7 +145,7 @@ def test_optimizer32bit(dim1, dim2, gtype, optim_name):
# since Lion can have pretty noisy updates where things lie at the boundary
# allow up to 10 errors for Lion
assert_most_approx_close
(
p1
,
p2
.
float
(),
atol
,
rtol
,
max_error_count
=
10
)
assert_most_approx_close
(
p1
,
p2
.
float
(),
atol
=
atol
,
rtol
=
rtol
,
max_error_count
=
10
)
if
i
%
(
k
//
5
)
==
0
and
i
>
0
:
path
=
get_temp_dir
()
...
...
@@ -157,7 +157,7 @@ def test_optimizer32bit(dim1, dim2, gtype, optim_name):
rm_path
(
path
)
# since Lion can have pretty noisy updates where things lie at the boundary
# allow up to 10 errors for Lion
assert_most_approx_close
(
p1
,
p2
.
float
(),
atol
,
rtol
,
max_error_count
=
10
)
assert_most_approx_close
(
p1
,
p2
.
float
(),
atol
=
atol
,
rtol
=
rtol
,
max_error_count
=
10
)
for
name1
,
name2
in
str2statenames
[
optim_name
]:
# since Lion can have pretty noisy updates where things lie at the boundary
# allow up to 10 errors for Lion
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment