torch.cuda

torch.cuda

表1 torch.cuda

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.can_device_access_peer

torch_npu.npu.can_device_access_peer

2

torch.cuda.current_blas_handle

torch_npu.npu.current_blas_handle

3

torch.cuda.current_device

torch_npu.npu.current_device

4

torch.cuda.current_stream

torch_npu.npu.current_stream

5

torch.cuda.default_stream

torch_npu.npu.default_stream

6

torch.cuda.device

torch_npu.npu.device

7

torch.cuda.device_count

torch_npu.npu.device_count

8

torch.cuda.device_of

torch_npu.npu.device_of

9

torch.cuda.get_arch_list

torch_npu.npu.get_arch_list

10

torch.cuda.get_device_capability

torch_npu.npu.get_device_capability

11

torch.cuda.get_device_name

torch_npu.npu.get_device_name

12

torch.cuda.get_device_properties

torch_npu.npu.get_device_properties

13

torch.cuda.get_gencode_flags

torch_npu.npu.get_gencode_flags

14

torch.cuda.get_sync_debug_mode

torch_npu.npu.get_sync_debug_mode

15

torch.cuda.init

torch_npu.npu.init

16

torch.cuda.ipc_collect

torch_npu.npu.ipc_collect

17

torch.cuda.is_available

torch_npu.npu.is_available

18

torch.cuda.is_initialized

torch_npu.npu.is_initialized

19

torch.cuda.memory_usage

torch_npu.npu.memory_usage

20

torch.cuda.set_device

torch_npu.npu.set_device

21

torch.cuda.set_stream

torch_npu.npu.set_stream

22

torch.cuda.set_sync_debug_mode

torch_npu.npu.set_sync_debug_mode

23

torch.cuda.stream

torch_npu.npu.stream

24

torch.cuda.StreamContext

torch_npu.npu.StreamContext

25

torch.cuda.synchronize

torch_npu.npu.synchronize

26

torch.cuda.utilization

torch_npu.npu.utilization

Random Number Generator

表2 Random Number Generator

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.get_rng_state

torch_npu.npu.get_rng_state

2

torch.cuda.get_rng_state_all

torch_npu.npu.get_rng_state_all

3

torch.cuda.initial_seed

torch_npu.npu.initial_seed

4

torch.cuda.manual_seed

torch_npu.npu.manual_seed

5

torch.cuda.manual_seed_all

torch_npu.npu.manual_seed_all

6

torch.cuda.seed

torch_npu.npu.seed

7

torch.cuda.seed_all

torch_npu.npu.seed_all

8

torch.cuda.set_rng_state

torch_npu.npu.set_rng_state

9

torch.cuda.set_rng_state_all

torch_npu.npu.set_rng_state_all

Communication collectives

表3 Communication collectives

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.comm.broadcast

torch_npu.npu.comm.broadcast

2

torch.cuda.comm.broadcast_coalesced

torch_npu.npu.comm.broadcast_coalesced

3

torch.cuda.comm.gather

torch_npu.npu.comm.gather

4

torch.cuda.comm.reduce_add

torch_npu.npu.comm.reduce_add

5

torch.cuda.comm.scatter

torch_npu.npu.comm.scatter

Streams and events

表4 Streams and events

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.Event

torch_npu.npu.Event

是,不支持from_ipc_handle和ipc_handle

2

torch.cuda.ExternalStream

torch_npu.npu.ExternalStream

3

torch.cuda.Stream

torch_npu.npu.Stream

Graphs (beta)

表5 Graphs

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.CUDAGraph

torch_npu.npu.CUDAGraph

2

torch.cuda.graph

torch_npu.npu.graph

3

torch.cuda.graph_pool_handle

torch_npu.npu.graph_pool_handle

4

torch.cuda.make_graphed_callables

torch_npu.npu.make_graphed_callables

Memory management

表6 Memory management

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.caching_allocator_alloc

torch_npu.npu.caching_allocator_alloc

2

torch.cuda.caching_allocator_delete

torch_npu.npu.caching_allocator_delete

3

torch.cuda.empty_cache

torch_npu.npu.empty_cache

4

torch.cuda.list_gpu_processes

torch_npu.npu.list_gpu_processes

5

torch.cuda.max_memory_allocated

torch_npu.npu.max_memory_allocated

6

torch.cuda.max_memory_cached

torch_npu.npu.max_memory_cached

7

torch.cuda.max_memory_reserved

torch_npu.npu.max_memory_reserved

8

torch.cuda.mem_get_info

torch_npu.npu.mem_get_info

9

torch.cuda.memory_allocated

torch_npu.npu.memory_allocated

10

torch.cuda.memory_cached

torch_npu.npu.memory_cached

11

torch.cuda.memory_reserved

torch_npu.npu.memory_reserved

12

torch.cuda.memory_snapshot

torch_npu.npu.memory_snapshot

13

torch.cuda.memory_stats

torch_npu.npu.memory_stats

14

torch.cuda.memory_summary

torch_npu.npu.memory_summary

15

torch.cuda.reset_max_memory_allocated

torch_npu.npu.reset_max_memory_allocated

16

torch.cuda.reset_max_memory_cached

torch_npu.npu.reset_max_memory_cached

17

torch.cuda.reset_peak_memory_stats

torch_npu.npu.reset_peak_memory_stats

18

torch.cuda.set_per_process_memory_fraction

torch_npu.npu.set_per_process_memory_fraction

NVIDIA Tools Extension (NVTX)

表7 NVIDIA Tools Extension

序号

API名称

npu对应API名称

是否支持

1

torch.cuda.nvtx.mark

torch_npu.npu.nvtx.mark

2

torch.cuda.nvtx.range_push

torch_npu.npu.nvtx.range_push

3

torch.cuda.nvtx.range_pop

torch_npu.npu.nvtx.range_pop