mindspore.hal.set_cur_stream

View Source On Gitee
mindspore.hal.set_cur_stream(stream)[source]

Sets the current stream.This is a wrapper API to set the stream. Usage of this function is discouraged in favor of the stream context manager.

Parameters

stream (Stream) – selected stream. This function is a no-op if this argument is None.

Raises

TypeError – If 'stream' is neither a mindspore.hal.Stream nor a None.

Examples

>>> import mindspore as ms
>>> cur_stream = ms.hal.current_stream()
>>> assert cur_stream == ms.hal.default_stream()
>>> s1 = ms.hal.Stream()
>>> ms.hal.set_cur_stream(s1)
>>> assert ms.hal.current_stream() == s1
>>> ms.hal.set_cur_stream(ms.hal.default_stream())