Sets the tensor's data.
Non-view (offset=0, storage covers exactly this tensor's numel): replaces the shared storage's data array in-place — all other views sharing the same TensorStorage immediately see the new values.
View (offset≠0 or storage is larger than this tensor):
copies values element-by-element into the shared storage at the
correct offset — the original tensor and sibling views are updated.
Optionalgrad: TensorReturns a view of this tensor along dimension 0.
The returned tensor shares the same underlying TensorStorage — mutations to either tensor (via zero_(), the data setter, or the optimizer) are immediately visible in the other.
Supports negative indices (e.g. index(-1) is the last row).
Note: the view does not carry a grad_fn; autograd does not propagate through index() at this time.
Optionaldim: number | number[]Optionaldim: number | number[]Optionaldim: number | number[]Optionaldim: numberOptionaldim: number | number[]
Returns the flat, contiguous data for this tensor.
Fast path (non-view): returns the storage array directly — no allocation. View path: materialises a contiguous slice — one allocation per call, so callers inside tight loops should cache the result:
const d = t.data.