npu.keep_dtype_scope

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

Specifies the operators that preserve the original precision. If the operator precision in an original network model is not supported by the Ascend AI Processor, the system automatically uses the high precision supported by the operators for compute.

Prototype

1
npu.keep_dtype_scope()

Parameters

None

Returns

Python context manager. Operators in the context have special attributes identified by the NPU.

Example

1
2
3
import npu_device as npu
with npu.keep_dtype_scope():
    v = tf.add(1, 1)