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.

Ascend GPU CPU

mindspore.hal.get_arch_list

Get the architecture list this MindSpore was compiled for.

Ascend GPU CPU

mindspore.hal.get_device_capability

Get specified device's capability.

Ascend GPU CPU

mindspore.hal.get_device_name

Get specified device's name.

Ascend GPU CPU

mindspore.hal.get_device_properties

Get specified device's properties.

Ascend GPU CPU

mindspore.hal.is_available

Returns whether specified backend is available.

Ascend GPU CPU

mindspore.hal.is_initialized

Returns whether specified backend is initialized.

Ascend GPU CPU

Stream

API Name

Description

Supported Platforms

mindspore.hal.current_stream

Return current stream used on this device.

Ascend GPU CPU

mindspore.hal.default_stream

Return default stream on this device.

Ascend GPU CPU

mindspore.hal.set_cur_stream

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

Ascend GPU CPU

mindspore.hal.synchronize

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

Ascend GPU CPU

mindspore.hal.Stream

Wrapper around a device stream.

Ascend GPU CPU

mindspore.hal.StreamCtx

Context-manager that selects a given stream.

Ascend GPU CPU

Event

API Name

Description

Supported Platforms

mindspore.hal.Event

Wrapper around a device event.

Ascend GPU CPU

Memory

API Name

Description

Supported Platforms

mindspore.hal.max_memory_allocated

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

Ascend GPU CPU

mindspore.hal.max_memory_reserved

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

Ascend GPU CPU

mindspore.hal.memory_allocated

Returns the actual memory size currently occupied by Tensor.

Ascend GPU CPU

mindspore.hal.memory_reserved

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

Ascend GPU CPU

mindspore.hal.memory_stats

Returns status information queried from the memory pool.

Ascend GPU CPU

mindspore.hal.memory_summary

Returns readable memory pool status information.

Ascend GPU CPU

mindspore.hal.reset_max_memory_reserved

Reset the peak memory size managed by the memory pool.

Ascend GPU CPU

mindspore.hal.reset_max_memory_allocated

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

Ascend GPU CPU

mindspore.hal.reset_peak_memory_stats

Reset the "peak" stats tracked by memory manager.

Ascend GPU CPU

mindspore.hal.empty_cache

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

Ascend GPU CPU