# tensorplay.set_float32_matmul_precision

Source: https://www.tensorplay.cn/docs/generated/tensorplay.set_float32_matmul_precision.html

# tensorplay.set_float32_matmul_precision

tensorplay.set_float32_matmul_precision(precision: [str](https://docs.python.org/3/library/stdtypes.html#str)) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay.html#set_float32_matmul_precision)

Sets the internal precision of float32 matrix multiplications.

Running float32 matrix multiplications in lower precision may significantly increase
performance, and in some programs the loss of precision has a negligible impact.

Supports three settings:

- “highest”, float32 matrix multiplications use the float32 datatype (24 mantissa bits with 23 bits explicitly stored) for internal computations.

- “high”, float32 matrix multiplications either use the TensorFloat32 datatype (10 mantissa bits explicitly stored) or treat each float32 number as the sum of two bfloat16 numbers (approximately 16 mantissa bits with 14 bits explicitly stored), if the appropriate fast matrix multiplication algorithms are available. Otherwise float32 matrix multiplications are computed as if the precision is “highest”. See below for more information on the bfloat16 approach.

- “medium”, float32 matrix multiplications use the bfloat16 datatype (8 mantissa bits with 7 bits explicitly stored) for internal computations, if a fast matrix multiplication algorithm using that datatype internally is available. Otherwise float32 matrix multiplications are computed as if the precision is “high”.

Note

This does not change the output dtype of float32 matrix multiplications,
it controls how the internal computation of the matrix multiplication is performed.

Note

This does not change the precision of convolution operations. Other flags,
like tensorplay.backends.cudnn.allow_tf32, may control the precision of convolution
operations.

Note

This flag currently only affects one native device type: CUDA.
If “high” or “medium” are set then the TensorFloat32 datatype will be used
when computing float32 matrix multiplications, equivalent to setting
tensorplay.backends.cuda.matmul.allow_tf32 = True. When “highest” (the default)
is set then the float32 datatype is used for internal computations, equivalent
to setting tensorplay.backends.cuda.matmul.allow_tf32 = False.

Parameters:

precision ([str](https://docs.python.org/3/library/stdtypes.html#str)) – can be set to “highest” (default), “high”, or “medium” (see above).
