ag_get_rows: Read buffer columns by index

View source: R/ag_buffer.R

ag_get_rowsR Documentation

Read buffer columns by index

Description

Selects columns of an ag_buffer by 0-based index, as a device operation: on the GPU only the indices cross the bus. The name follows ggml_get_rows, which selects along the second ggml dimension (ne1); in the R rows x capacity view that is a column.

Usage

ag_get_rows(buf, idx)

Arguments

buf

An ag_buffer.

idx

0-based column indices: a numeric vector, or an ag_tensor with one column (f32; indices are exact below 2^{24}).

Details

The result is a rows x length(idx) ag_tensor without gradient, usable as an input to further ag_* operations. Inside ag_capture() pass idx as an argument of the captured function: the recording is then reused for every index vector of the same length (the batch size is part of the recording's shape), and the buffer must be listed in params so that freeing it invalidates the recording.

Indices given as host values are checked against the buffer and an index out of range is an error. An index tensor already on the device (inside a recording) cannot be checked; on the device every index is clamped to 0..capacity-1 before the read, so an index out of range reads the first or last column instead of memory outside the buffer.

Value

An ag_tensor of shape rows x length(idx).


ggmlR documentation built on Oct. 23, 2026, 1:07 a.m.