View Source Rein.Utils.CircularBuffer (rein v0.1.0)

Circular Buffer utility via Nx Containers.

Summary

Functions

Append an item to the current buffer.

Append multiple items to the buffer.

Returns the data starting at the current index.

Functions

Append an item to the current buffer.

If the buffer data has shape {a, b, c, ...}, item must have shape {b, c, ...}

Link to this function

append_multiple(buffer, items)

View Source

Append multiple items to the buffer.

Works in a similar fashion to append/2, but receives a tensor with shape equal to the buffer data except for the first axis, which will be the number of items to be appended.

Link to this function

new(shape, opts \\ [init_value: 0, type: :f32])

View Source

Creates a new Elixir.Rein.Utils.CircularBuffer with a given shape.

Options

  • :init_value - a number or tensor that will be broadcasted to shape. Defaults to 0. If the value given is vectorized, the buffer will be vectorized accordingly, but all entries will share the same current index and size.

  • :type - the type for the tensor if :init_value. Defaults to :f32

Returns the data starting at the current index.

The oldest persisted entry will be the first entry in the result, and so on.