Skip to content
fn

linspace_op

→TensorImplPtr
int linspace_op(double start, double stop, int num, Dtype dt, Device device, bool requires_grad)

Python wrappers

Public Python APIs implemented by this engine symbol.

Create a 1-D tensor with num linearly spaced values from start to stop inclusive.

Math

Element ii equals start+i⋅(stop−start)/(num−1)\text{start} + i \cdot (\text{stop} - \text{start}) / (\text{num} - 1); the final element is pinned to stop exactly to avoid floating-point drift.

Parameters

startdouble
First value (inclusive).
stopdouble
Last value (inclusive).
numint64_t
Number of samples (must be ≥0\ge 0).
dtDtype
Element dtype.
deviceDevice
Target device.
requires_gradbool
Attach a fresh autograd leaf when true.

Returns

TensorImplPtr

1-D tensor of length num.

Raises

LucidError
If num < 0.