mindspore.hal.StreamCtx
- class mindspore.hal.StreamCtx(ctx_stream)[source]
- Context-manager that selects a given stream, this api will be deprecated and removed in future versions, please use the api - mindspore.runtime.StreamCtxinstead.- All kernels queued within its context will be enqueued on a selected stream. - Parameters
- ctx_stream (Stream) – selected stream. This manager is a no-op if it's - None.
 - Examples - >>> import mindspore >>> a = mindspore.tensor(mindspore.ops.ones([1024, 2048]), mindspore.float32) >>> b = mindspore.tensor(mindspore.ops.ones([2048, 4096]), mindspore.float32) >>> s1 = mindspore.hal.Stream() >>> with mindspore.hal.StreamCtx(s1): ... c = mindspore.ops.matmul(a, b) >>> mindspore.hal.synchronize() >>> assert s1.query()