PyTorch torch.wait 関数


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

torch.waitこれは PyTorch で待機するための関数です。CPU と GPU の操作を同期するために使用します。

関数定義

torch.wait(tensor)

使用例

例

import torch

# テンソルを作成(CUDA が利用可能な場合は GPU を使用)
if torch.cuda.is_available():
    x = torch.tensor([1, 2, 3]).cuda()
    torch.wait(x)
    print("Wait completed on CUDA tensor")
else:
    x = torch.tensor([1, 2, 3])
    torch.wait(x)
    print("Wait completed on CPU tensor")

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

その他の拡張