Skip to content

Commit 757003e

Browse files
ezyangfacebook-github-bot
authored andcommitted
Add some more tests for impl_abstract in other parts of test code (pytorch#2098)
Summary: Sorry about the rapid fire PRs, I was expecting land to stop if OSS CI failed but it didn't lol Differential Revision: D50696761
1 parent 79f38e4 commit 757003e

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

fbgemm_gpu/test/sparse_ops_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
from itertools import accumulate
1818
from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union
1919

20+
import fbgemm_gpu
21+
2022
import hypothesis.strategies as st
2123
import numpy as np
2224
import torch
@@ -2424,7 +2426,11 @@ def validate(
24242426
}
24252427

24262428
# only generate tests on nightly pytorch (current release version is 2.1)
2427-
if torch.__version__ >= "2.2.*":
2429+
if (
2430+
torch.__version__ >= "2.2.*"
2431+
and hasattr(torch.library, "impl_abstract")
2432+
and not hasattr(fbgemm_gpu, "open_source")
2433+
):
24282434
generate_opcheck_tests(
24292435
SparseOpsTest,
24302436
["fb", "fbgemm"],

fbgemm_gpu/test/test_utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from functools import wraps
1414
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
1515

16+
import fbgemm_gpu
17+
1618
import hypothesis.strategies as st
1719
import numpy as np
1820
import torch
@@ -204,7 +206,11 @@ def cpu_and_maybe_gpu() -> st.SearchStrategy[List[torch.device]]:
204206

205207

206208
def has_optests() -> bool:
207-
return torch.__version__ >= "2.2.*"
209+
return (
210+
torch.__version__ >= "2.2.*"
211+
and hasattr(torch.library, "impl_abstract")
212+
and not hasattr(fbgemm_gpu, "open_source")
213+
)
208214

209215

210216
class optests:

0 commit comments

Comments
 (0)