jax.numpy.empty

Contents

jax.numpy.empty#

jax.numpy.empty(shape, dtype=None, *, device=None)[source]#

Return a new array of given shape and type, without initializing entries.

LAX-backend implementation of numpy.empty().

Because XLA cannot create uninitialized arrays, the JAX version will return an array initialized with zeros.

Original docstring below.

Parameters:
  • shape (int or tuple of int) – Shape of the empty array, e.g., (2, 3) or 2.

  • dtype (data-type, optional) – Desired output data-type for the array, e.g, numpy.int8. Default is numpy.float64.

  • device (xc.Device | Sharding | None)

Returns:

out – Array of uninitialized (arbitrary) data of the given shape, dtype, and order. Object arrays will be initialized to None.

Return type:

ndarray