-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added CPython free-threading support and basic CI env
+ multithread tests + wheels job
- Loading branch information
Showing
12 changed files
with
82 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
# Add ml_dtypes/tests folder to discover multi_thread_utils.py module | ||
sys.path.insert(0, str(Path(__file__).parent)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from concurrent.futures import ThreadPoolExecutor | ||
from functools import wraps | ||
|
||
|
||
def multi_threaded(*, num_workers: int): | ||
def decorator(test_cls): | ||
for name, test_fn in test_cls.__dict__.copy().items(): | ||
if not (name.startswith("test") and callable(test_fn)): | ||
continue | ||
|
||
@wraps(test_fn) | ||
def multi_threaded_test_fn(*args, __test_fn__=test_fn, **kwargs): | ||
with ThreadPoolExecutor(max_workers=num_workers) as executor: | ||
futures = [] | ||
for _ in range(num_workers): | ||
futures.append(executor.submit(__test_fn__, *args, **kwargs)) | ||
# We should call future.result() to re-raise an exception if test has failed | ||
list(f.result() for f in futures) | ||
|
||
setattr(test_cls, f"{name}_multi_threaded", multi_threaded_test_fn) | ||
|
||
return test_cls | ||
|
||
return decorator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters