PyTorch torch.wait function
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")
# 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")
Other extensions