Poplar and PopLibs
poplar::DebugInfo Class Reference

DebugInfo stores and persists a set of data that describes the context of an operation. More...

#include <DebugContext.hpp>

Inherited by poputil::OpDebugInfo.

Public Member Functions

 DebugInfo (const DebugContext &debugContext, std::string layer)
 Constructor. More...
 
DebugId getId () const
 Gets the unique identifier of this DebugInfo object.
 
std::string getPathName () const
 Gets the pathname of this object (as received from DebugContext).
 
bool setValue (std::string name, ProfileValue value)
 Adds custom data to this object if "name" is not already set. More...
 

Static Public Member Functions

static void initializeStreamer (const std::string &fileName, const DebugSerializationFormat &format=DebugSerializationFormat::CBOR)
 Initializes the streamer, unless it is already initialized (for example through env variables). More...
 
static void closeStreamer ()
 Closes the streamer: all data is flushed to disk and the file is ready to be read. More...
 

Detailed Description

DebugInfo stores and persists a set of data that describes the context of an operation.

Some of that data is structured, such as the framework layer name (Poplar, PopLibs, PopART, and so on) or the file and line of the source code. But it can also be custom data set by the user through setValue method.

In turn, the DebugInfo is passed to sub-operations of that operation so that resources (Program, Variable, and other object types) created in lower levels can be hierarchically related to the initial DebugInfo.

After execution, the created DebugInfo has been written to a file. At the same time, the operation resources have been persisted in the graph and execution profile, together with their DebugInfo ID. In this way, tools like PopVision can conveniently present to the user: the operation, its resources, and its DebugInfo.

This class is expected to be derived to adapt to particular use cases (typically, by adding extra mandatory arguments to the constructor). Internally, derived classes can use setValue() to store the extra data to be persisted.

At object destruction, the DebugInfo data is passed to the streamer to be written to a file. Thus, the streamer should be initialized before any DebugInfo object gets destroyed, or it will not be persisted.

Constructor & Destructor Documentation

◆ DebugInfo()

poplar::DebugInfo::DebugInfo ( const DebugContext debugContext,
std::string  layer 
)

Constructor.

Parameters
debugContextCaptures the external context of the operation (for example, file and line of invocation).
layerName of the framework level (for example, Poplar, PopLibs or PopART).

Member Function Documentation

◆ closeStreamer()

static void poplar::DebugInfo::closeStreamer ( )
static

Closes the streamer: all data is flushed to disk and the file is ready to be read.

DebugInfo objects destroyed after this point will not be persisted.

◆ initializeStreamer()

static void poplar::DebugInfo::initializeStreamer ( const std::string &  fileName,
const DebugSerializationFormat format = DebugSerializationFormat::CBOR 
)
static

Initializes the streamer, unless it is already initialized (for example through env variables).

Parameters
fileNameThe name of the file where all DebugInfo objects will be persisted.
formatThe format of the file (JSON or CBOR).

◆ setValue()

bool poplar::DebugInfo::setValue ( std::string  name,
ProfileValue  value 
)

Adds custom data to this object if "name" is not already set.

Parameters
nameThe key name of the data.
valueA ProfileValue object containing the custom data.
Returns
true if "name" was not already set, false otherwise.

The documentation for this class was generated from the following file: