3#ifndef poplar_VertexIntrospector_hpp
4#define poplar_VertexIntrospector_hpp
6#include <poplar/GraphElements.hpp>
7#include <poplar/Target.hpp>
8#include <poplar/TypeTraits.hpp>
9#include <poplar/VectorLayout.hpp>
10#include <poplar/exceptions.hpp>
19class VertexIntrospector;
43 std::size_t
size()
const {
return value; }
101 static_assert(TypeTraits::isSimpleType<T>(),
102 "getInitialValue() called with invalid type");
105 throw poplar_error(
"You may not call getInitialValue() on a non-scalar "
106 "(use getInitalValues() - with an 's')");
109 const auto traits = TypeTraits::make<T>();
118 template <
typename T>
121 throw poplar_error(
"You may not call getInitialValues() on a scalar "
122 "(use getInitalValue() - no 's')");
125 std::vector<T> result(
size());
129 getInitialValuesOverload(target, result);
135 FieldData(std::unique_ptr<core::FieldData> fd);
138 std::unique_ptr<core::FieldData> impl;
141 template <
typename T>
142 void getInitialValuesOverload(
const Target &target,
143 std::vector<T> &result)
const {
144 static_assert(TypeTraits::isSimpleType<T>(),
145 "getInitialValues() called with invalid type");
148 throw poplar_error(
"getInitialValues() must be called with a "
149 "std::vector<T> for 1D fields");
152 auto traits = TypeTraits::make<T>();
158 template <
typename T>
159 void getInitialValuesOverload(
const Target &target,
160 std::vector<std::vector<T>> &result)
const {
161 static_assert(TypeTraits::isSimpleType<T>(),
162 "getInitialValues() called with invalid type");
165 throw poplar_error(
"getInitialValues() must be called with a "
166 "std::vector<std::vector<T>> for 1D fields");
169 auto traits = TypeTraits::make<T>();
170 for (
auto i = 0u; i < result.size(); ++i) {
174 if (!result[i].empty()) {
181 const Target &target,
void *dst,
const TypeTraits &traits,
208 std::unique_ptr<core::VertexIntrospector> impl;
A reference to a compute set within a graph.
Definition: GraphElements.hpp:131
Information about a vertex field, including its size and its initial value, if set.
Definition: VertexIntrospector.hpp:39
T getInitialValue(const Target &target) const
Get the inital value for a scalar field.
Definition: VertexIntrospector.hpp:100
SizeT operator[](std::size_t i) const
Determine size of field.
Definition: VertexIntrospector.hpp:91
std::string name() const
Return the name of the vertex field.
layout::Vector getProfilerVectorLayout(std::size_t nestingLevel) const
Determine the layout for vector fields.
std::vector< T > getInitialValues(const Target &target) const
Get the initial value for a 1D or 2D vector field.
Definition: VertexIntrospector.hpp:119
std::size_t size() const
Determine the size of the field.
std::size_t getSizeAtIndex(std::size_t i) const
Determine the size of the sub-vector for 2D fields.
layout::VectorList getProfilerVectorListLayout() const
For VectorList fields, return the layout.
unsigned rank() const
Return the rank of the field.
A target representation.
Definition: Target.hpp:69
Available to cycle estimators to inspect the shape and initial values of a vertex's fields.
Definition: VertexIntrospector.hpp:188
ComputeSet getComputeSet() const
Return the compute set that this vertex is in.
FieldData getFieldInfo(const std::string &name) const
Information about the vertex field.
half2 max(half2 src0, half2 src1)
Targets the f16v2max instruction.
Definition: ipu_intrinsics:333
Vector
An enumeration used to state what type of pointer is used for a Vector vertex field.
Definition: VectorLayout.hpp:15
VectorList
An enumeration used to state what type of pointer is used for a VectorList vertex field.
Definition: VectorLayout.hpp:31
Poplar classes and functions.
Definition: ArrayRef.hpp:14
Base class for Poplar exceptions.
Definition: exceptions.hpp:16