cutcutcodec.core.opti.parallel.threading¶
Thread utils.
Classes
|
Context manager to set the number of torch threads. |
Functions
|
Return the number of threads. |
Details
- class cutcutcodec.core.opti.parallel.threading.TorchThreads(threads: Integral)[source]
Context manager to set the number of torch threads.
Examples¶
>>> import torch >>> from cutcutcodec.core.opti.parallel.threading import TorchThreads >>> (t := torch.get_num_threads()) != 1 True >>> with TorchThreads(1): ... torch.get_num_threads() ... 1 >>> torch.get_num_threads() == t True >>>
Initialise the thread setter.
Parameters¶
- threadsint
The number of threads, same as
get_num_threads.