mindspore.ops.NPUClearFloatStatus

class mindspore.ops.NPUClearFloatStatus[source]

Clears the flag which stores the overflow status.

Note

The flag is in the register on the Ascend device. It will be reset and can not be reused again after the NPUClearFloatStatus is called. In addition, there are strict sequencing requirements for use, i.e., before using the NPUGetFloatStatus operator, need to ensure that the NPUClearFlotStatus and your compute has been executed. We use Depend to ensure the execution order.

Examples: see NPUGetFloatStatus.

Inputs:
  • x (Tensor) - The output tensor of NPUAllocFloatStatus. The data type must be float16 or float32.

Outputs:

Tensor, has the same shape as x. All the elements in the tensor will be zero.

Supported Platforms:

Ascend

Examples

>>> self.alloc_status = ops.NPUAllocFloatStatus()
>>> self.get_status = ops.NPUGetFloatStatus()
>>> self.clear_status = ops.NPUClearFloatStatus()
>>> init = self.alloc_status()
>>> init = F.Depend(init, input)  # Ensure clear_status after input
>>> clear_status = self.clear_status(init)
>>> input = F.Depend(input, clear_status)  # Ensure your compute after clear_status
>>> output = Compute(input)
>>> init = F.Depend(init, output)
>>> flag = self.get_status(init)  # Ensure get_status after your compute
>>> self.clear_status(init)
>>> print(init)
[0. 0. 0. 0. 0. 0. 0. 0.]