8#ifndef poputil_VertexTemplates_hpp
9#define poputil_VertexTemplates_hpp
10#include <poplar/Type.hpp>
15inline std::string templateVertexParams(
bool first) {
22template <
typename... Args>
23inline std::string templateVertexParams(
bool first,
const std::string &val,
26template <
typename... Args>
27inline std::string templateVertexParams(
bool first,
const char *val,
30template <
typename... Args>
31inline std::string templateVertexParams(
bool first,
const poplar::Type &type,
34template <
typename... Args>
35inline std::string templateVertexParams(
bool first,
bool b, Args &&...args);
37template <
typename T>
struct VertexTemplateToString {
38 static std::string to_string(
const T &x) {
return std::to_string(x); }
41template <>
struct VertexTemplateToString<
poplar::StringRef> {
42 static std::string to_string(
const poplar::StringRef &ref) {
return ref; }
45template <
typename T,
typename... Args>
46inline std::string templateVertexParams(
bool first,
const T &val,
48 std::string p = first ?
"<" :
",";
49 p += VertexTemplateToString<T>::to_string(val) +
50 templateVertexParams(
false, std::forward<Args>(args)...);
54template <
typename... Args>
55inline std::string templateVertexParams(
bool first,
const poplar::Type &type,
57 std::string p = first ?
"<" :
",";
59 templateVertexParams(
false, std::forward<Args>(args)...);
63template <
typename... Args>
64inline std::string templateVertexParams(
bool first,
const std::string &val,
66 std::string p = first ?
"<" :
",";
67 p += val + templateVertexParams(
false, std::forward<Args>(args)...);
71template <
typename... Args>
72inline std::string templateVertexParams(
bool first,
const char *val,
74 std::string p = first ?
"<" :
",";
75 p += val + templateVertexParams(
false, std::forward<Args>(args)...);
79template <
typename... Args>
80inline std::string templateVertexParams(
bool first,
bool b, Args &&...args) {
81 std::string p = first ?
"<" :
",";
82 auto bstr = (b ?
"true" :
"false");
83 p += bstr + templateVertexParams(
false, std::forward<Args>(args)...);
95template <
typename... Args>
97 return name + templateVertexParams(
true, std::forward<Args>(args)...);
Class representing device data types.
Definition: Type.hpp:42
StringRef toString() const
Get a string representation on a type.
Poplar classes and functions.
Definition: ArrayRef.hpp:14
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