Skip to content
module

creation

35 members
lucid.creation

Tensor 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 share one default generator but consume it differently per draw — a CPU rand(4) advances its counter by 4, a Metal rand(4) by one block — so the same seed does not reproduce the same stream across devices; comparing them means comparing deterministic ops, replaying state with get_rng_state() / set_rng_state(), or eval() for anything stochastic.

Classes

Functions