PyTorch 文档¶
PyTorch 是一个针对使用 GPU 和 CPU 进行深度学习的优化张量库。
本文档中描述的功能按发布状态分类
稳定版: 这些功能将长期维护,并且通常不应该存在重大的性能限制或文档缺失。我们还希望保持向后兼容性(尽管可能会发生重大更改,并且会提前一个版本发布通知)。
测试版: 这些功能被标记为测试版,因为 API 可能会根据用户反馈而更改,因为性能需要改进,或者因为运算符的覆盖范围尚不完整。对于测试版功能,我们承诺将其推进到稳定版分类。但是,我们不承诺向后兼容性。
原型: 这些功能通常不作为二进制发行版(如 PyPI 或 Conda)的一部分提供,除了有时在运行时标志后面,并且处于早期阶段以供反馈和测试。
开发者说明
语言绑定
Python API
- torch
- torch.nn
- torch.nn.functional
- torch.Tensor
- 张量属性
- 张量视图
- torch.amp
- torch.autograd
- torch.library
- torch.cpu
- torch.cuda
- StreamContext
- torch.cuda.can_device_access_peer
- torch.cuda.current_blas_handle
- torch.cuda.current_device
- torch.cuda.current_stream
- torch.cuda.default_stream
- device
- torch.cuda.device_count
- device_of
- torch.cuda.get_arch_list
- torch.cuda.get_device_capability
- torch.cuda.get_device_name
- torch.cuda.get_device_properties
- torch.cuda.get_gencode_flags
- torch.cuda.get_sync_debug_mode
- torch.cuda.init
- torch.cuda.ipc_collect
- torch.cuda.is_available
- torch.cuda.is_initialized
- torch.cuda.memory_usage
- torch.cuda.set_device
- torch.cuda.set_stream
- torch.cuda.set_sync_debug_mode
- torch.cuda.stream
- torch.cuda.synchronize
- torch.cuda.utilization
- torch.cuda.temperature
- torch.cuda.power_draw
- torch.cuda.clock_rate
- torch.cuda.OutOfMemoryError
- 随机数生成器
- 通信集合
- 流和事件
- 图(测试版)
- 内存管理
- NVIDIA 工具扩展 (NVTX)
- Jiterator(测试版)
- TunableOp
- 流清理器(原型)
- 了解 CUDA 内存使用情况
- 生成快照
- 使用可视化工具
- 快照 API 参考
- torch.mps
- torch.xpu
- StreamContext
- torch.xpu.current_device
- torch.xpu.current_stream
- device
- torch.xpu.device_count
- device_of
- torch.xpu.empty_cache
- torch.xpu.get_device_capability
- torch.xpu.get_device_name
- torch.xpu.get_device_properties
- torch.xpu.init
- torch.xpu.is_available
- torch.xpu.is_initialized
- torch.xpu.set_device
- torch.xpu.set_stream
- torch.xpu.stream
- torch.xpu.synchronize
- 随机数生成器
- 流和事件
- torch.mtia
- 元设备
- torch.backends
- torch.export
- torch.distributed
- torch.distributed.algorithms.join
- torch.distributed.elastic
- torch.distributed.fsdp
完全分片数据并行(FullyShardedDataParallel)
反向预取(BackwardPrefetch)
分片策略(ShardingStrategy)
混合精度(MixedPrecision)
CPU 卸载(CPUOffload)
状态字典配置(StateDictConfig)
完整状态字典配置(FullStateDictConfig)
分片状态字典配置(ShardedStateDictConfig)
本地状态字典配置(LocalStateDictConfig)
优化器状态字典配置(OptimStateDictConfig)
完整优化器状态字典配置(FullOptimStateDictConfig)
分片优化器状态字典配置(ShardedOptimStateDictConfig)
本地优化器状态字典配置(LocalOptimStateDictConfig)
状态字典设置(StateDictSettings)
- torch.distributed.optim
- torch.distributed.pipelining
- torch.distributed.tensor.parallel
- torch.distributed.checkpoint
save()
async_save()
save_state_dict()
load()
load_state_dict()
异步暂存器(AsyncStager)
阻塞异步暂存器(BlockingAsyncStager)
有状态(Stateful)
存储读取器(StorageReader)
存储写入器(StorageWriter)
加载计划器(LoadPlanner)
加载计划(LoadPlan)
读取项(ReadItem)
保存计划器(SavePlanner)
保存计划(SavePlan)
写入项(WriteItem)
文件系统读取器(FileSystemReader)
文件系统写入器(FileSystemWriter)
默认保存计划器(DefaultSavePlanner)
默认加载计划器(DefaultLoadPlanner)
get_state_dict()
get_model_state_dict()
get_optimizer_state_dict()
set_state_dict()
set_model_state_dict()
set_optimizer_state_dict()
状态字典选项(StateDictOptions)
dcp_to_torch_save()
torch_save_to_dcp()
广播 Torch 保存读取器(BroadcastingTorchSaveReader)
动态元数据加载计划器(DynamicMetaLoadPlanner)
- torch.distributions
- torch.compiler
- torch.fft
- torch.func
- torch.futures
- torch.fx
- torch.fx.experimental
- torch.hub
- torch.jit
- torch.linalg
- torch.monitor
- torch.signal
- torch.special
- torch.overrides
- torch.package
- torch.profiler
- torch.nn.init
- torch.nn.attention
- torch.onnx
- torch.optim
- 复数
- DDP 通信钩子
- 量化
- 分布式 RPC 框架
- torch.random
- torch.masked
- torch.nested
- torch.Size
- torch.sparse
- torch.Storage
类型化存储(TypedStorage)
非类型化存储(UntypedStorage)
双精度存储(DoubleStorage)
单精度存储(FloatStorage)
半精度存储(HalfStorage)
长整型存储(LongStorage)
整型存储(IntStorage)
短整型存储(ShortStorage)
字符存储(CharStorage)
字节存储(ByteStorage)
布尔存储(BoolStorage)
BFloat16 存储(BFloat16Storage)
复数双精度存储(ComplexDoubleStorage)
复数单精度存储(ComplexFloatStorage)
QUInt8 存储(QUInt8Storage)
QInt8 存储(QInt8Storage)
QInt32 存储(QInt32Storage)
QUInt4x2 存储(QUInt4x2Storage)
QUInt2x4 存储(QUInt2x4Storage)
- torch.testing
- torch.utils
- torch.utils.benchmark
- torch.utils.bottleneck
- torch.utils.checkpoint
- torch.utils.cpp_extension
- torch.utils.data
- torch.utils.deterministic
- torch.utils.jit
- torch.utils.dlpack
- torch.utils.mobile_optimizer
- torch.utils.model_zoo
- torch.utils.tensorboard
- torch.utils.module_tracker
- 类型信息
- 命名张量
- 命名张量运算符覆盖范围
- torch.__config__
- torch.__future__
- torch._logging
- Torch 环境变量