PyTorch torch.set_num_interop_threads function
PyTorch torch reference manual
torch.set_num_interop_threads is a function in PyTorch used to set the number of inter-op parallel threads. These threads are used to execute different independent operations in parallel.
Function definition
torch.set_num_interop_threads(num_threads)
Parameter Description
num_threads: the number of inter-op threads to set
Usage examples
Example
import
torch
Set the number of inter-op threads
torch.
set_num_interop_threads
(
4
)
(
"Number of inter-op threads set to:"
,
torch.
get_num_interop_threads
(
)
)
Restore the default value
torch.
set_num_interop_threads
(
1
)
(
"Default number of inter-op threads restored"
)
The output is:
跨域线程数已设置为: 4
已恢复默认跨域线程数