Poplar and PopLibs
poplar::FieldData Class Reference

Information about a vertex field, including its size and its initial value, if set. More...

#include <VertexIntrospector.hpp>

Public Member Functions

unsigned rank () const
 Return the rank of the field. More...
 
std::size_t size () const
 Determine the size of the field. More...
 
std::size_t getSizeAtIndex (std::size_t i) const
 Determine the size of the sub-vector for 2D fields. More...
 
layout::Vector getProfilerVectorLayout (std::size_t nestingLevel) const
 Determine the layout for vector fields. More...
 
layout::VectorList getProfilerVectorListLayout () const
 For VectorList fields, return the layout. More...
 
SizeT operator[] (std::size_t i) const
 Determine size of field. More...
 
std::string name () const
 Return the name of the vertex field.
 
template<typename T >
getInitialValue (const Target &target) const
 Get the inital value for a scalar field. More...
 
template<typename T >
std::vector< T > getInitialValues (const Target &target) const
 Get the initial value for a 1D or 2D vector field. More...
 

Detailed Description

Information about a vertex field, including its size and its initial value, if set.

This is used when calculating cycle estimates.

Vertex fields can be scalar, 1D or 2D. For example:

  • Scalar: float, Input<float>.
  • 1D: Vector<float>, Input<Vector<float>>
  • 2D: Input<VectorList<float>>, Vector<Input<Vector<float>>>

The sizes of vertex fields can always be returned, and the initial values can be returned for non-edge fields (float, Vector<float>) and edge fields (Input and so on) that are connected to constants.

Note that 2D fields are vectors of vectors, in other words they are jagged 2D arrays.

Member Function Documentation

◆ getInitialValue()

template<typename T >
T poplar::FieldData::getInitialValue ( const Target target) const
inline

Get the inital value for a scalar field.

T must be of type scalar. Throws an error if this is not a scalar field.

◆ getInitialValues()

template<typename T >
std::vector< T > poplar::FieldData::getInitialValues ( const Target target) const
inline

Get the initial value for a 1D or 2D vector field.

For 1D fields, T should be a scalar type (for example, float) and for 2D fields, T should be std::vector<>. Throws an error if this is a scalar field.

◆ getProfilerVectorLayout()

layout::Vector poplar::FieldData::getProfilerVectorLayout ( std::size_t  nestingLevel) const

Determine the layout for vector fields.

Parameters
iThe dimension to query, 0 for the outer vector, 1 for the inner.
Returns
The layout for vector fields.

◆ getProfilerVectorListLayout()

layout::VectorList poplar::FieldData::getProfilerVectorListLayout ( ) const

For VectorList fields, return the layout.

We only support introspecting a VectorList that is the outermost vector.

◆ getSizeAtIndex()

std::size_t poplar::FieldData::getSizeAtIndex ( std::size_t  i) const

Determine the size of the sub-vector for 2D fields.

Throws an error if called on non-2D fields.

Parameters
iIndex of the sub-vector in the 2D field.
Returns
Return the size of the sub-vector for 2D fields.

◆ operator[]()

SizeT poplar::FieldData::operator[] ( std::size_t  i) const
inline

Determine size of field.

This is an alternate to getSizeAtIndex(). Instead of field.getSizeAtIndex(i) you can use field[i].size().

◆ rank()

unsigned poplar::FieldData::rank ( ) const

Return the rank of the field.

  • 0 for scalar fields
  • 1 for 1D
  • 2 for 2D.

◆ size()

std::size_t poplar::FieldData::size ( ) const

Determine the size of the field.

Returns
For scalar fields it returns 1, for 1D fields it returns the size of the vector, and for 2D fields it returns the number of sub-vectors.

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