PyTorch torch.set_num_interop_threads 関数


Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

torch.set_num_interop_threadsこれは、PyTorch で inter-op(操作間)並列スレッド数を設定するための関数です。これらのスレッドは、独立した異なる操作を並列に実行するために使われます。

関数定義

torch.set_num_interop_threads(num_threads)

パラメータの説明

  • num_threads: 設定する inter-op スレッド数

使用例

実例

import torch

# inter-op スレッド数を設定
torch.set_num_interop_threads(4)

print("inter-op スレッド数は次のように設定されました:", torch.get_num_interop_threads())

# デフォルト値を復元
torch.set_num_interop_threads(1)

print("デフォルトの inter-op スレッド数を復元しました")

出力結果は次のとおりです:

跨域线程数已设置为: 4
已恢复默认跨域线程数

Pytorch torch 参考手册Pytorch torch リファレンスマニュアル

その他の拡張