#include <poplar/Quarter.hpp>

Quarter precision floating-point type definitions for IPU software.

The quarter type is a single byte floating-point format internal to Poplar. The format is fully defined at runtime using an independently allocated metadata variable. Typically, a single metadata variable is used to define the format for an arbitrary number of elements of type quarter. The metadata is of type QuarterMetadata and it includes the following information:

  • An enumeration that defines the number of bits of the quarter data that is used for sign, mantissa and exponent.

  • A signed scale factor.

The scale factor is applied when converting from quarter to float or vice-versa. In the following code, d is of type float, q is of type quarter, and QuarterMetadata has scale factor s:

d = q * pow(2, s)
q = d * pow(2, -s)

namespace poplar

Poplar classes and functions.


std::ostream &operator<<(std::ostream &os, const QuarterMetadata &md)
class QuarterMetadata
#include <Quarter.hpp>

Quarter metadata type.

The floating-point format for data of type quarter is determined at IPU runtime. This runtime format definition is called “metadata”. The sign, mantissa, exponent and scaling of the underlying quarter data type are fully defined by the metadata and are encoded in the underlying value in the way expected by poplar runtime. No arithmetic operations are supported on this type.

Public Types

enum class Format

Format specification for 8-bit floats.


enumerator F143

1 bit for sign, 4 bits for exponent, 3 bits for mantissa

enumerator F152

1 bit for sign, 5 bits for exponent, 2 bits for mantissa

Public Functions

QuarterMetadata() = default
inline explicit QuarterMetadata(const Format fmt, const signed char scale)
inline explicit QuarterMetadata(unsigned char value)
inline QuarterMetadata(const QuarterMetadata &other)
QuarterMetadata &operator=(const QuarterMetadata &other)
bool operator==(const QuarterMetadata other) const
bool operator!=(const QuarterMetadata other) const
inline unsigned char getBinary() const
inline unsigned char &data()
inline const unsigned char &data() const
Format getFormat() const
signed char getScale() const
std::string toString() const

Private Functions

unsigned char pack(const Format fmt, const signed char scale) const

Private Members

unsigned char value