CircBuf

#include <popops/CircBuf.hpp>

Circular buffer support.

namespace popops

Common functions, such as elementwise and reductions.

class CircBuf

Public Functions

CircBuf(poplar::Graph &graph, const poplar::Type &dataType, unsigned size, const std::vector<std::size_t> &shape, const poplar::DebugContext &debugContext = {})

CircBuf represents a circular buffer of tensors which can be indexed using prev().

Each call to add() will add the given tensor to the circular buffer with the potential to overwrite a previous element if the buffer is full.

Parameters
  • graph – Graph to add the circular buffer to.

  • dataType – Datatype of the tensor elements in buffer.

  • size – Size of the circular buffer.

  • shape – Shape of the tensor elements in buffer.

  • debugContext – Optional debug information.

poplar::Tensor prev(unsigned i, poplar::program::Sequence &seq, const poplar::DebugContext &debugContext = {})

Return elements i entries old.

i must be less size.

Parameters
  • i – Index into the circular buffer.

  • seq – Program to add the operation to.

  • debugContext – Optional debug information.

Returns

Tensor returned from the circular buffer.

void add(poplar::Tensor t, poplar::program::Sequence &seq, const poplar::DebugContext &debugContext = {})

Append an element to the end of the circular buffer.

Parameters
  • t – Tensor to append to the circular buffer

  • seq – Program to add the operation to.

  • debugContext – Optional debug information.

poplar::Tensor getIndex() const

Tensor representing the index into the circular buffer.

unsigned size() const

Size of the circular buffer.

poplar::Graph::TileToTensorMapping getTileMapping()
Returns

Tensor mapping of the tensor returned by indexing into a circular buffer.

Private Members

poplar::Graph &graph
unsigned size_
poplar::Tensor index
std::vector<std::size_t> shape
unsigned padElements
poplar::Tensor hist