creation
30 memberslucid.creationTensor construction, and the seeding of the default generator.
Thirty entry points: conversion (tensor, as_tensor, from_numpy), filled and *_like constructors, the range builders arange / linspace, the sampling family, the generator controls (seed, get_rng_state / set_rng_state, initial_seed, randperm) and DLPack exchange.
Every constructor takes device=, and passing it is what keeps a pipeline on one device: a helper built without it lands on the CPU and forces a round trip the moment it meets Metal data.
CPU and Metal draw from separate generators, so one seed does not reproduce one stream across both — comparing devices means comparing deterministic ops, or eval() for anything stochastic.
Functions
tensor→ TensorConstruct a new Tensor from Python data, a NumPy array, or another Tensor.
as_tensor→ TensorConvert data to a tensor, avoiding a copy when the source already matches.
from_numpy→ TensorCreate a CPU tensor from a NumPy ndarray with shared storage.
zeros→ TensorReturn a tensor filled with the additive identity element, zero.
ones→ TensorReturn a tensor filled with the multiplicative identity element, one.
empty→ TensorReturn a tensor whose elements are uninitialised (undefined memory).
full→ TensorReturn a tensor filled with a constant scalar value.
eye→ TensorReturn a 2-D matrix with ones on the main diagonal and zeros elsewhere.
arange→ TensorReturn a 1-D tensor of evenly spaced values over a half-open interval.
linspace→ TensorReturn a 1-D tensor of steps equally spaced values over a closed interval.
zeros_like→ TensorReturn a zero-filled tensor with the same shape, dtype, and device as t.
ones_like→ TensorReturn an all-ones tensor with the same shape, dtype, and device as t.
empty_like→ TensorReturn an uninitialised tensor with the same shape, dtype, and device as t.
full_like→ TensorReturn a constant-filled tensor with the same shape, dtype, and device as t.
logspace→ TensorReturn a 1-D tensor of steps values evenly spaced on a logarithmic scale.
manual_seed→ NoneSet the seed of the default Philox counter-based random number generator.
rand→ TensorReturn a tensor of samples drawn from the continuous uniform distribution.
randn→ TensorReturn a tensor of samples drawn from the standard normal distribution.
randint→ TensorReturn a tensor of samples drawn from the discrete uniform distribution.
bernoulli→ TensorReturn a tensor of independent Bernoulli trials with success probability p.
normal→ TensorReturn a tensor of samples drawn from a parametric normal distribution.
rand_like→ TensorReturn a random tensor with the same shape, dtype, and device as t.
randn_like→ TensorReturn a random tensor with the same shape, dtype, and device as t.
from_dlpack→ TensorConstruct a Lucid tensor from any object exposing the DLPack
protocol (__dlpack__) or from a raw PyCapsule.
get_rng_state→ TensorSnapshot the full state of the default random generator.
initial_seed→ intReturn the seed (key) of the default generator as it was last set.
randperm→ TensorReturn a uniformly random permutation of the integers .
seed→ intSeed the default generator from the OS cryptographic entropy source.
set_rng_state→ NoneRestore the default random generator to a previously captured state.
to_dlpack→ objectExport t as a DLPack PyCapsule.