本章节包含各种子模块接口,如随机数、内存管理等。
API名称 |
说明 |
---|---|
检测NPU计算过程中是否有数值溢出。 |
|
对NPU芯片溢出检测为进行清零。 |
|
功能和调用方式与torch.backends.cuda.matmul.allow_tf32类似。 |
|
功能和调用方式与torch.backends.cudnn.allow_tf32类似。 |
|
详细使用参见《PyTorch 训练模型迁移调优指南》中的“设置算子编译选项”章节。 |
|
是否使用私有格式,设置为True时允许使用私有格式,设置为False时,不允许申请任何私有格式的tensor,避免了适配层出现私有格式流通。 |
|
提供硬件精度在线检测接口,供模型调用。 |
|
停止对应device上的计算,对于没有执行的计算进行清除,后续在此device上执行计算会报错。 |
|
恢复对应device上的状态,后续在此device上进行计算可以继续进行计算执行。 |
|
提供故障内存地址类型检测接口,供MindCluster进行故障恢复策略的决策。其功能是在出现UCE片上内存故障时,判断故障内存地址类型。 |
|
创建一条同步下发NPUStream,在该流上下发的任务不再使用taskqueue异步下发。 |
|
判断当前使用的溢出检测模式,True为INF_NAN模式,False为饱和模式。 |
|
检测梯度是否溢出,INF_NAN模式下检测输入Tensor是否溢出;饱和模式检查硬件溢出标志位判断。 |
API名称 |
说明 |
---|---|
获取NPU设备支持的数据类型,可能设备支持不止一种数据类型。 |
|
确认autocast是否可用。 |
|
是否在设备上使能AMP。 |
|
在amp场景获取设备支持的数据类型,该dtype由torch_npu.npu.set_autocast_dtype设置或者默认数据类型torch.float16。 |
|
设置设备在AMP场景支持的数据类型。 |
API接口 |
说明 |
---|---|
(beta)torch_npu.npu.get_rng_state |
Torch_npu提供随机数相关的部分接口,具体可参考torch.cuda。 |
(beta)torch_npu.npu.set_rng_state |
|
(beta)torch_npu.npu.get_rng_state_all |
|
(beta)torch_npu.npu.set_rng_state_all |
|
(beta)torch_npu.npu.manual_seed |
|
(beta)torch_npu.npu.manual_seed_all |
|
(beta)torch_npu.npu.seed |
|
(beta)torch_npu.npu.seed_all |
|
(beta)torch_npu.npu.initial_seed |
API名称 |
说明 |
---|---|
传入配置文件来配置dump参数。 |
|
初始化dump配置。 |
|
结束dump。 |
|
设置是否开启二进制。 |
|
确认算子计算是否采用的二进制,如果是二进制计算,返回True,否则返回False。 |
|
设置线性module里面的mm和bmm算子是否用ND格式。 |
|
确认线性module里面的mm和bmm算子是否有使能ND格式,如果使能了ND,返回True,否则,返回False。 |
|
torch_npu提供设备相关的部分接口。 |
API接口 |
说明 |
---|---|
(beta)torch_npu.npu.caching_allocator_alloc |
Torch_npu提供内存管理相关的部分接口,具体可参考torch.cuda。 |
(beta)torch_npu.npu.caching_allocator_delete |
|
(beta)torch_npu.npu.set_per_process_memory_fraction |
|
(beta)torch_npu.npu.empty_cache |
|
(beta)torch_npu.npu.memory_stats |
|
(beta)torch_npu.npu.memory_stats_as_nested_dict |
|
(beta)torch_npu.npu.reset_accumulated_memory_stats |
|
(beta)torch_npu.npu.reset_peak_memory_stats |
|
(beta)torch_npu.npu.reset_max_memory_allocated |
|
(beta)torch_npu.npu.reset_max_memory_cached |
|
(beta)torch_npu.npu.memory_allocated |
|
(beta)torch_npu.npu.max_memory_allocated |
|
(beta)torch_npu.npu.memory_reserved |
|
(beta)torch_npu.npu.max_memory_reserved |
|
(beta)torch_npu.npu.memory_cached |
|
(beta)torch_npu.npu.max_memory_cached |
|
(beta)torch_npu.npu.memory_snapshot |
|
(beta)torch_npu.npu.memory_summary |
|
torch.npu.npu.NPUPluggableAllocator |
该接口涉及高危操作,使用请参考torch.npu.npu.NPUPluggableAllocator。 |
torch.npu.npu.change_current_allocator |
该接口涉及高危操作,使用请参考torch.npu.npu.change_current_allocator。 |
API名称 |
说明 |
---|---|
AOE调优使能。 |
API名称 |
说明 |
---|---|
打点接口。 |
|
标记瞬时事件。 |
|
标识打点开始。 |
|
标识打点结束。 |
|
range装饰器,用来采集被装饰函数的range执行耗时。 |
API接口 |
说明 |
---|---|
torch_npu.npu.BoolStorage |
功能和调用方式与torch.Storage相同,具体请参考https://pytorch.org/docs/stable/storage.html#。 |
torch_npu.npu.ByteStorage |
|
torch_npu.npu.ShortStorage |
|
torch_npu.npu.LongStorage |
|
torch_npu.npu.IntStorage |
|
torch_npu.npu.HalfStorage |
|
torch_npu.npu.CharStorage |
|
torch_npu.npu.DoubleStorage |
|
torch_npu.npu.FloatStorage |
API名称 |
说明 |
---|---|
查询aclnn版本信息。 |
|
设置conv算子是否支持hf32,一个属性值,对aclnn的allow_hf32属性的设置和查询。 |
PyTorch原生API名称 |
NPU形式名称 |
是否支持 |
参考链接 |
---|---|---|---|
torch.cuda.DoubleTensor |
torch_npu.npu.DoubleTensor |
是 |
|
torch.cuda.ShortTensor |
torch_npu.npu.ShortTensor |
是 |
|
torch.cuda.CharTensor |
torch_npu.npu.CharTensor |
是 |
|
torch.cuda.ByteTensor |
torch_npu.npu.ByteTensor |
是 |
|
torch.cuda.FloatTensor |
torch_npu.npu.FloatTensor |
是 |
|
torch.cuda.HalfTensor |
torch_npu.npu.HalfTensor |
是 |
|
torch.cuda.IntTensor |
torch_npu.npu.IntTensor |
是 |
|
torch.cuda.BoolTensor |
torch_npu.npu.BoolTensor |
是 |
|
torch.cuda.LongTensor |
torch_npu.npu.LongTensor |
是 |