PopART Python API Reference

Introduction

The Poplar Advanced Run Time (PopART) is part of the Poplar SDK for implementing and running algorithms on networks of Graphcore IPU processors.

This document describes the PopART Python API. Many classes are wrappers around the equivalent C++ class, for example popart.builder.Builder wraps the C++ Builder class (renamed BuilderCore in pybind). See the PopART C++ API for details.

For more information about PopART, please refer to the PopART User Guide.

PopART Python API

Sessions

class popart.session.InferenceSession(fnModel, dataFeed, deviceInfo, losses=[], inputShapeInfo=<popart_core.InputShapeInfo object>, passes=None, userOptions=<popart_core.SessionOptions object>)

Bases: popart_core._InferenceSessionCore

initAnchorArrays()
prepareDevice(self: popart_core._InferenceSessionCore, err: popart_core.PrepareDeviceError) → None
exception popart.session.PrepareDeviceException(e)

Bases: popart_core.popart_exception

getGraphReport()
getSummaryReport()
class popart.session.TrainingSession(fnModel, dataFeed, losses, optimizer, deviceInfo, inputShapeInfo=<popart_core.InputShapeInfo object>, passes=None, userOptions=<popart_core.SessionOptions object>)

Bases: popart_core._TrainingSessionCore

initAnchorArrays()
prepareDevice(self: popart_core._TrainingSessionCore, err: popart_core.PrepareDeviceError) → None

Builder

class popart.builder.Builder(modelProtoOrFilename=None, opsets=None)

Bases: popart_core._BuilderCore

property aiGraphcore
property aiOnnx
property aiOnnxMl
reshape_const(aiOnnx, args, shape, debugPrefix='')

Tensor information

class popart.tensorinfo.TensorInfo(dtype, shape)

Bases: popart_core._TensorInfoCore

TensorInfo(numpy.ndarray)

Writer

Framework independent functionality for driving popart

class popart.writer.NetWriter(inNames, outNames, losses, optimizer, dataFeed, inputShapeInfo)

Bases: object

Base class, to be inherited once per framework

eval(inputsMap)

perform batchesPerStep evaluation steps. This function only needs to be implemented by frameworks which will be used to verify popart. See torchwriter.py for an example implementation.

infer(inputsMap)

perform batchesPerStep inference steps. This function only needs to be implemented by frameworks which will be used to verify popart. See torchwriter.py for an example implementation.

saveModel(filename)

To be implemented once per framework: framework specific details of generating the ONNX model and writing it to file

train(inputsMap)

perform batchesPerStep training steps. This function only needs to be implemented by frameworks which will be used to verify popart. See torchwriter.py for an example implementation.