Skip to content
fn

rand_op

→TensorImplPtr
int rand_op(const int & shape, Dtype dt, Device device, Generator * gen)

Python wrappers

Public Python APIs implemented by this engine symbol.

Allocates a tensor filled with uniform samples on [0,1)[0, 1).

Convenience wrapper around uniform_op with low = 0 / high = 1.

Math

xi∼U(0,1)x_i \sim \mathcal{U}(0, 1)

See Also

uniform_op — arbitrary [low,high)[low, high) interval. randn_op — Gaussian variant.

Parameters

shapeconst Shape&
Shape of the output tensor.
dtDtype
Element dtype. Floating-point dtypes only (F32, F64, BF16, F16).
deviceDevice
Memory domain of the output (CPU or GPU).
genGenerator*= None
Bit-stream state to draw from. When nullptr (the default), uses default_generator.

Returns

TensorImplPtr

Newly allocated leaf tensor (requires_grad = false) of the requested shape / dtype / device.