mindspore.hal.synchronize

查看源文件
mindspore.hal.synchronize()[源代码]

同步当前设备上的所有流,此接口将在后续版本中废弃,请使用接口 mindspore.runtime.synchronize() 代替。

样例:

>>> 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()