8#ifndef poputil_cyclesTables_hpp
9#define poputil_cyclesTables_hpp
11#include <poplar/Graph.hpp>
12#include <poplar/PerfEstimateFunc.hpp>
13#include <poplar/Target.hpp>
14#include <poplar/VertexIntrospector.hpp>
36#define MAKE_PERF_ESTIMATOR_NAME(codelet) getPerfEstimateFor##codelet
37#define CYCLE_ESTIMATOR_ENTRY_NOPARAMS(ns, codelet) \
38 poputil::internal::makePerfEstimatorEntry(#ns "::" #codelet, \
39 MAKE_PERF_ESTIMATOR_NAME(codelet))
40#define CYCLE_ESTIMATOR_ENTRY(ns, codelet, ...) \
41 poputil::internal::makePerfEstimatorEntry( \
42 #ns "::" #codelet, MAKE_PERF_ESTIMATOR_NAME(codelet), __VA_ARGS__)
46#define CODELET_FIELD(field) const auto field = vertex.getFieldInfo(#field)
47#define CODELET_SCALAR_VAL(field, type) \
48 const auto field = vertex.getFieldInfo(#field).getInitialValue<type>(target);
49#define CODELET_VECTOR_VALS(field, type) \
50 const auto field = vertex.getFieldInfo(#field).getInitialValues<type>(target);
51#define CODELET_VECTOR_2D_VALS(field, type) \
53 vertex.getFieldInfo(#field).getInitialValues<std::vector<type>>(target);
58using PerfEstimatorTable =
59 std::vector<std::pair<std::string, poplar::PerfEstimateFunc>>;
61template <
typename F,
typename... Args>
62inline std::pair<std::string, poplar::PerfEstimateFunc>
63makePerfEstimatorEntry(
const std::string &codelet, F f, Args &&...args) {
64 using std::placeholders::_1;
65 using std::placeholders::_2;
66 return std::make_pair(
68 std::bind(f, _1, _2, std::forward<Args>(args)...));
72 const PerfEstimatorTable &table) {
73 for (
auto &kv : table) {
80 case poplar::layout::Vector::NotAVector:
81 case poplar::layout::Vector::Span:
82 case poplar::layout::Vector::OnePtr:
84 case poplar::layout::Vector::ShortSpan:
86 case poplar::layout::Vector::ScaledPtr32:
89 case poplar::layout::Vector::ScaledPtr64:
90 case poplar::layout::Vector::ScaledPtr128:
100 case poplar::layout::VectorList::NotAVector:
101 case poplar::layout::VectorList::OnePtr:
102 case poplar::layout::VectorList::ScaledPtr32:
103 case poplar::layout::VectorList::ScaledPtr64:
104 case poplar::layout::VectorList::ScaledPtr128:
106 case poplar::layout::VectorList::DeltaN:
107 return poputil::internal::getUnpackCost(
108 poplar::layout::Vector::ScaledPtr32);
109 case poplar::layout::VectorList::DeltaNElements:
121 case poplar::layout::VectorList::NotAVector:
122 case poplar::layout::VectorList::OnePtr:
123 case poplar::layout::VectorList::ScaledPtr32:
124 case poplar::layout::VectorList::ScaledPtr64:
125 case poplar::layout::VectorList::ScaledPtr128:
127 case poplar::layout::VectorList::DeltaN:
130 case poplar::layout::VectorList::DeltaNElements:
Generate a string describing a vertex type.
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
void registerPerfEstimator(StringRef vertexTypeName, PerfEstimateFunc f)
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
std::function< VertexPerfEstimate(const VertexIntrospector &v, const Target &target)> PerfEstimateFunc
Functions of this type can be used as performance estimator callbacks for new vertex types.
Definition: PerfEstimateFunc.hpp:25
General utility functions for building graphs.
Definition: GfloatExprUtil.hpp:23
std::string templateVertex(const std::string &name, Args &&...args)
Generate a string representation of a Vertex type for use by poplar::Graph::addVertex().
Definition: VertexTemplates.hpp:96
Define a PopLibs exception.
Class for PopLibs exceptions.
Definition: exceptions.hpp:17