本章节包含各种子模块接口,如随机数、内存管理等。
API名称 |
说明 |
---|---|
检测npu计算过程中是否有数值溢出。 |
|
对npu芯片溢出检测为进行清零。 |
|
功能和调用方式与torch.backends.cuda.matmul.allow_tf32类似。 |
|
功能和调用方式与torch.backends.cudnn.allow_tf32类似。 |
|
详细使用参见《PyTorch 训练模型迁移调优指南》的“设置算子编译选项”章节。 |
|
是否使用私有格式,设置为True时允许使用私有格式,设置为False时,不允许申请任何私有格式的tensor,避免了适配层出现私有格式流通。 |
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 |
API名称 |
说明 |
---|---|
AOE调优使能。 |
API名称 |
说明 |
---|---|
查询当前aclnn的版本信息,当前版本还没有支持正确的aclnn的版本,兼容返回None同时做warn提示torch.npu.aclnn.version isn't implemented! |
|
设置conv算子是否支持hf32,一个属性值,对aclnn的allow_hf32属性的设置和查询,默认值为true。 |
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 |
是 |