PyTorch torch.wait function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.waitIt is a function in PyTorch used for waiting. It is used to synchronize CPU and GPU operations.

Function definition

torch.wait(tensor)

Usage example

Example

import torch

# Create a tensor (use GPU if CUDA is available)
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 Reference Manual

Other extensions