mindspore.runtime.synchronize

View Source On Gitee
mindspore.runtime.synchronize()[source]

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

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore as ms
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> ms.set_device("Ascend", 0)
>>> a = Tensor(np.ones([1024, 2048]), ms.float32)
>>> b = Tensor(np.ones([2048, 4096]), ms.float32)
>>> s1 = ms.runtime.Stream()
>>> with ms.runtime.StreamCtx(s1):
...     c = ops.matmul(a, b)
>>> ms.runtime.synchronize()
>>> assert s1.query()