onnx_light.backend.random#

Deterministic pseudo-random helpers.

This module is a thin Python wrapper around the C++ implementation in onnx_light.onnx_backend_test exposed through the _onnxpy.backend nanobind submodule. The behavior is bit-identical to the prior pure-Python implementation.

onnx_light.backend.random.rand(*shape: int, seed: int | integer | None = None) ndarray#

Returns deterministic uniform random values in [0, 1).

Parameters:
  • shape – Output dimensions. When empty, returns a scalar.

  • seed – Optional integer seed.

Returns:

A np.ndarray of float64 values with the requested shape.

onnx_light.backend.random.randint(low: int, high: int | None = None, size: int | Iterable[int] | None = None, seed: int | integer | None = None, dtype=<class 'numpy.int64'>) ndarray#

Returns deterministic pseudo-random integers.

Parameters:
  • low – Lower bound, inclusive. If high is None, this becomes the exclusive upper bound and the lower bound becomes 0.

  • high – Exclusive upper bound.

  • size – Output size. Must not be None.

  • seed – Optional integer seed.

  • dtype – Integer dtype of the output.

Returns:

A np.ndarray of integers with the requested shape.

onnx_light.backend.random.randn(*shape: int, seed: int | integer | None = None) ndarray#

Returns deterministic pseudo-random values with an approximate normal distribution.

Samples are produced using the Irwin-Hall approximation (sum of 12 uniform values minus 6), which approximates a normal distribution.

Parameters:
  • shape – Output dimensions. When empty, returns a scalar.

  • seed – Optional integer seed.

Returns:

A np.ndarray of float64 values with the requested shape.