mindspore.hal

Hal encapsulates interfaces for device, stream, event, and memory. MindSpore abstracts the corresponding modules from different backends, allowing users to schedule hardware resources at the Python layer.

Device

API Name

Description

Supported Platforms

mindspore.hal.device_count

Returns device count of specified backend.

mindspore.hal.get_arch_list

Get the architecture list this MindSpore was compiled for.

mindspore.hal.get_device_capability

Get specified device's capability.

mindspore.hal.get_device_name

Get specified device's name.

mindspore.hal.get_device_properties

Get specified device's properties.

mindspore.hal.is_available

Returns whether specified backend is available.

mindspore.hal.is_initialized

Returns whether specified backend is initialized.

Stream

API Name

Description

Supported Platforms

mindspore.hal.communication_stream

Return default stream on this device.

mindspore.hal.current_stream

Return current stream used on this device.

mindspore.hal.default_stream

Return default stream on this device.

mindspore.hal.set_cur_stream

Sets the current stream.This is a wrapper API to set the stream.

mindspore.hal.synchronize

Synchronize all streams on current device.(Each MindSpore process only occupies one device)

mindspore.hal.Stream

Wrapper around a device stream.

mindspore.hal.StreamCtx

Context-manager that selects a given stream.

Event

API Name

Description

Supported Platforms

mindspore.hal.Event

Wrapper around a device event.

Memory

API Name

Description

Supported Platforms

mindspore.hal.contiguous_tensors_handle.combine_tensor_list_contiguous

Return a contiguous memory handle where contiguous memory has been requested and slicing functionality is provided.

mindspore.hal.contiguous_tensors_handle.ContiguousTensorsHandle

ContiguousTensorsHandle is a handle manage continuous memory.

mindspore.hal.max_memory_allocated

Returns the peak memory size of the memory pool actually occupied by Tensor since the process was started.

mindspore.hal.max_memory_reserved

Returns the peak value of the total memory managed by the memory pool since the process was started.

mindspore.hal.memory_allocated

Returns the actual memory size currently occupied by Tensor.

mindspore.hal.memory_reserved

Returns the total amount of memory currently managed by the memory pool.

mindspore.hal.memory_stats

Returns status information queried from the memory pool.

mindspore.hal.memory_summary

Returns readable memory pool status information.

mindspore.hal.reset_max_memory_reserved

Reset the peak memory size managed by the memory pool.

mindspore.hal.reset_max_memory_allocated

Reset the peak memory size of the memory pool actually occupied by Tensor.

mindspore.hal.reset_peak_memory_stats

Reset the "peak" stats tracked by memory manager.

mindspore.hal.empty_cache

Release all memory fragments in the memory pool, so that memory arrangement will be optimized.