ClikaRT::graph::Transform
class
Header: ClikaRT/graph/transform.h
Transform: a graph transform the runtime can run over a ModelGraph: one of ours, from its factory in transforms (transforms::fusion_driver()), or one you write (Transform::from_function, or transforms::rewrite for a rule over a Pattern, rewrite.h).
A handle of ours names a transform and carries nothing else: the graph that runs it supplies the settings it depends on, so a factory takes no arguments. A handle you make carries your function. kind() is the typed key (TransformKind::User for yours); name() is the transform's name, the factory's own spelling or the name you gave, readable in every build. Two handles of ours compare equal when they name the same kind; a handle you made equals its copies only.
Compare and persist a transform by its NAME, never by the integer behind its TransformKind: the values follow the runtime's transform list and move whenever the list changes.
A list of handles is what ModelGraph::optimize runs (OptimizeOptions::transforms, optimize.h); ModelGraph::default_transforms and transforms::defaults (optimize.h) return the default lists.
Macros
#define CLIKART_DETAIL_TRANSFORM_KIND_ENUMERATOR
#define CLIKART_DETAIL_TRANSFORM_KIND_ENUMERATOR(kind, name) kind,
Declared in ClikaRT/graph/transform.h, line 46
#define CLIKART_DETAIL_TRANSFORM_FACTORY
#define CLIKART_DETAIL_TRANSFORM_FACTORY(kind, name) CLIKART_PUBLIC_EXPORT Transform name();
Declared in ClikaRT/graph/transform.h, line 152
A graph transform: one of ours, from its factory in transforms, or one you write (from_function). Cheap to copy.
Static member functions
from_function()
static Transform from_function(
std::string name,
TransformFunction fn,
std::vector<Transform> runs_after = {}
)
A transform you write, which ModelGraph::optimize runs beside ours at its place in OptimizeOptions::transforms, once per iteration.
name: how the transform reads in the report and in errors. Not empty and never the name of one of ours. Within one list no two different transforms share a name; one handle may be listed more than once, as ours may.fn: edits the graph it is handed (model_graph.h lists the edits and what a transform may not do) and returns a failure to stop the run; a throw it makes is caught on your side and read as that failure. The run counts it as changing the graph when one of its edits did.runs_after: the transforms, ours or yours, it must follow in any list that holds both:optimizerefuses a list that places it ahead of one of them. One the list does not hold asks nothing.
Refuses InvalidArgument for an empty name, the name of one of ours, an empty fn, and a runs_after entry that is another transform of the same name.
Declared in ClikaRT/graph/transform.h, line 116
Member functions
kind()
TransformKind kind() const noexcept
Which transform this handle names: TransformKind::User for one you made.
Declared in ClikaRT/graph/transform.h, line 124
name()
std::string name() const
The transform's name: "fusion_driver" for transforms::fusion_driver(), the name you gave for one you made.
Declared in ClikaRT/graph/transform.h, line 128
Friends
operator==
friend bool operator==(const Transform& a, const Transform& b) noexcept
Two handles of ours naming the same kind compare equal; a handle you made equals its copies only.
Declared in ClikaRT/graph/transform.h, line 132