5. Managing devices

To manage connections with IPU devices, Model Runtime defines a set of helper classes that create an abstraction of a device to allow for easier device management.

5.1. Device

The Device class is a thin wrapper around the Poplar Device. Device extends poplar::Device with the following characteristics:

Note

The Device class is not intended to be used directly by the user. To create a Device use DeviceManager (Section 5.2, Device Manager).

5.2. Device Manager

The DeviceManager class provides an interface for managing devices available in the user system. From a programmer’s perspective, it is a builder class that creates Device objects for the user.

Note

DeviceManager does not own the Device objects it creates. Full ownership is transferred to the user.

To create a Device suitable for the user model and representing a physical IPU, one of the following DeviceManager methods can be used:

If the user does not have any IPUs available in the system, or for any other reason does not want to operate on a physical IPU, DeviceManager still can be used to create Device objects representing IPU models.

Methods dedicated for that task are createIpuModelDevice(int64_t, int64_t, int64_t) and createIpuModelDevice(std::shared_ptr<popef::Model>, int64_t).

Note

Both versions of the createIpuModelDevice function accept the tiles_per_ipu parameter as the last arguments. The value of the parameter sets up the number of tiles per IPU to be simulated. The larger this value set up, the longer the simulated computations take.

model_runtime::DeviceManager mgr;
const int64_t number_of_ipus = 1;
const int64_t ipu_version = 2;
const int64_t tiles_per_ipu = 100;
std::shared_ptr<model_runtime::Device> device =
  mgr.createIpuModelDevice(number_of_ipus, ipu_version, tiles_per_ipu);

The last two methods: createSmallIpuModelDevice(int64_t, int64_t) and createSmallIpuModelDevice(std::shared_ptr<popef::Model>) deliver shortcuts for creating a Device referring to a “small” IPU model (only 4 tiles per IPU).

model_runtime::DeviceManager mgr;
const int64_t number_of_ipus = 1;
const int64_t ipu_version = 2;
std::shared_ptr<model_runtime::Device> device =
  mgr.createSmallIpuModelDevice(number_of_ipus, ipu_version);