PyTorch torch.use_deterministic_algorithms Function


Pytorch torch 参考手册Pytorch torch Reference Manual

torch.use_deterministic_algorithmsIt is a function in PyTorch for using deterministic algorithms. It sets whether to use deterministic algorithms when possible.

Function Definition

torch.use_deterministic_algorithms(enabled, warn_only=False)

Usage Example

Example

import torch

# Enable deterministic algorithms
torch.use_deterministic_algorithms(True)

# Check whether it is enabled
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")

# Disable deterministic algorithms
torch.use_deterministic_algorithms(False)
print(f"Using deterministic algorithms: {torch.are_deterministic_algorithms_enabled()}")

Pytorch torch 参考手册Pytorch torch Reference Manual

Other Extensions