# tensorplay.use_deterministic_algorithms

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

# tensorplay.use_deterministic_algorithms

tensorplay.use_deterministic_algorithms(mode: [bool](https://docs.python.org/3/library/functions.html#bool), *, warn_only: [bool](https://docs.python.org/3/library/functions.html#bool) = False) &#x2192; [None](https://docs.python.org/3/library/constants.html#None)[[source]](../_modules/tensorplay.html#use_deterministic_algorithms)

Sets whether TensorPlay operations must use “deterministic”
algorithms. That is, algorithms which, given the same input, and when
run on the same software and hardware, always produce the same output.
When enabled, operations will use deterministic algorithms when available,
and if only nondeterministic algorithms are available they will throw a
[RuntimeError](https://docs.python.org/3/library/exceptions.html#RuntimeError) when called.

Note

This setting alone is not always enough to make an application
reproducible. Refer to [Reproducibility](../upstream_labels.html#reproducibility) for more information.

Note

[tensorplay.set_deterministic_debug_mode()](tensorplay.set_deterministic_debug_mode.html#tensorplay.set_deterministic_debug_mode) offers an alternative
interface for this feature.

Note that deterministic operations tend to have worse performance than
nondeterministic operations.

Note

This flag does not detect or prevent nondeterministic behavior caused
by calling an inplace operation on a tensor with an internal memory
overlap or by giving such a tensor as the out argument for an
operation. In these cases, multiple writes of different data may target
a single memory location, and the order of writes is not guaranteed.

Parameters:

mode ([bool](https://docs.python.org/3/library/functions.html#bool)) – If True, makes potentially nondeterministic
operations switch to a deterministic algorithm or throw a runtime
error. If False, allows nondeterministic operations.

Keyword Arguments:

warn_only ([bool](https://docs.python.org/3/library/functions.html#bool), optional) – If True, operations that do not
have a deterministic implementation will throw a warning instead of
an error. Default: False

Example:

```
>>> # xdoctest: +SKIP
>>> tensorplay.use_deterministic_algorithms(True)
```
