Skip to content
fn

uniform_op

→TensorImplPtr
int uniform_op(const int & shape, double low, double high, Dtype dt, Device device, Generator * gen)

Python wrappers

Public Python APIs implemented by this engine symbol.

Allocates a tensor filled with uniform samples on [low,high)[\mathrm{low}, \mathrm{high}).

Math

xi∼U(low,high)x_i \sim \mathcal{U}(\mathrm{low}, \mathrm{high})

See Also

rand_op — convenience shortcut for [0,1)[0, 1).

Parameters

shapeconst Shape&
Shape of the output tensor.
lowdouble
Inclusive lower bound of the support.
highdouble
Exclusive upper bound of the support. Must be strictly greater than low.
dtDtype
Element dtype. Floating-point only.
deviceDevice
Memory domain (CPU or GPU).
genGenerator*= None
Bit-stream state; falls back to default_generator on nullptr.

Returns

TensorImplPtr

Newly allocated leaf tensor (requires_grad = false).

Raises

LucidError
If high <= low — surfaced as ValueError on the Python side.