Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.set_num_interop_threads function

PyTorch torch.set_num_interop_threads function


PyTorch torch reference manual 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


Usage examples

Example

import

torch

Set the number of inter-op threads

torch.

set_num_interop_threads

(

4

)

print

(

"Number of inter-op threads set to:"

,

torch.

get_num_interop_threads

(

)

)

Restore the default value

torch.

set_num_interop_threads

(

1

)

print

(

"Default number of inter-op threads restored"

)

The output is:

跨域线程数已设置为: 4

已恢复默认跨域线程数


PyTorch torch reference manual PyTorch torch reference manual