3. Using the Poplar library

The Poplar library provides classes and functions to implement graph programs. These can be accessed by including the appropriate header files. For example:

#include <poplar/Graph.hpp>
#include <poplar/Program.hpp>
#include <poplar/Engine.hpp>

using namespace poplar;

You do not need any special command line tools to compile Poplar programs. You just use the standard host C++ compiler and link with the Poplar library, as shown below:

$ g++ -std=c++11 my-program.cpp -lpoplar

The header files are in the include/poplar directory of the Poplar installation. The library file is the lib directory.

The main classes defined in the Poplar library are summarised below.

  • Graph: The class used to create a graph structure defining the connections between tensors and operations.

  • Device: Represents a physical device or simulation that will execute a graph.

  • Tensor: A class for representing and operating on tensors.

  • Type: Represents data types on the target device (to distinguish them from types on the host). These include:

    • INT: 32-bit integer

    • SHORT: 16-bit integer

    • CHAR: 8-bit integer (signed by default)

    • FLOAT: IEEE 32-bit floating point

    • HALF: IEEE 16-bit floating point

    • BOOL: Boolean value (stored as one byte)

  • Program: The base class for creating control programs that define how vertices will be executed. Complex control programs can be built up by combining sub-programs in various ways. The sub-classes for creating and combining programs include:

    • Execute: The basic class for creating a program from a compute set

    • Sequence: Executes a sequence of sub-programs sequentially

    • Repeat: Execute a sub-program a fixed number of times

    • If: Conditionally execute a sub-program

  • Engine: From a graph and one or more control programs, creates an object that can be used to execute the graph on a device.

For full details of all the classes and functions in the Poplar library, see the Poplar and PopLibs API Reference.