set_device_sat_mode

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

×

Atlas inference products

×

Atlas training products

Description

Sets the process-level overflow mode for floating-point compute. Two overflow modes are supported: saturation mode and Inf/NaN mode.
  • Saturation mode: When overflow occurs during compute, the compute result is saturated as the floating-point extremum (+-MAX).
  • Inf/NaN mode: Complies with IEEE 754 and outputs the Inf/NaN compute result based on the definition.

For the Atlas training products, the default (and the only supported) mode is saturation mode.

For the Atlas A2 training products/Atlas A2 inference products, the overflow/underflow mode can be saturation or Inf/NaN. Retain the default Inf/NaN mode. The saturation mode is used only for compatibility with earlier versions and will not evolve in the future. In addition, the computing accuracy in this mode may be unreliable.

For the Atlas A3 training products/Atlas A3 inference products, the overflow/underflow mode can be saturation or Inf/NaN. Retain the default Inf/NaN mode. The saturation mode is used only for compatibility with earlier versions and will not evolve in the future. In addition, the computing accuracy in this mode may be unreliable.

Prototype

1
def set_device_sat_mode(mode)

Parameters

Parameter

Input/Output

Description

mode

Input

Specified overflow mode.

  • 0: saturation mode.
  • 1: INF/NaN mode.

For the Atlas training products, the default (and the only supported) value is 0.

For the Atlas A2 training products/Atlas A2 inference products, use the default value 1.

For the Atlas A3 training products/Atlas A3 inference products, use the default value 1.

Returns

None

Constraints

None

Example

The following example applies only to the Atlas A2 training products/Atlas A2 inference productsAtlas A3 training products/Atlas A3 inference products. For other processors, you do not need to explicitly call this API.

1
2
3
4
5
6
import tensorflow as tf
import npu_device as npu
# Initialize the NPU as the default device.
npu.open().as_default() 
# For the Atlas A2 training products/Atlas A2 inference products, the following API is called to set the overflow mode during network execution:
npu.npu_device.set_device_sat_mode(1)