Skip to content
fn

randint_op

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

Python wrappers

Public Python APIs implemented by this engine symbol.

Allocates an integer tensor filled with samples drawn uniformly from the integer interval [low,high)[\mathrm{low}, \mathrm{high}).

Math

\mathrm{high}-1\}$$

Parameters

shapeconst Shape&
Shape of the output tensor.
lowint64_t
Inclusive lower bound.
highint64_t
Exclusive upper bound; must be strictly greater than low.
dtDtype
Integer dtype (I32, I64, U8 …).
deviceDevice
Memory domain.
genGenerator*= None
Bit-stream state.

Returns

TensorImplPtr

Newly allocated leaf integer tensor (requires_grad = false).

Notes

The integer dtype must be wide enough to represent every value in [low,high)[\mathrm{low}, \mathrm{high}) losslessly; the underlying Storage helper does not mask or wrap on overflow.