#include "GraphBuilderContext.h"
#include "GraphBuilderRegistry.h"
+#include "Transforms/Transform.h"
+
#include <loco/IR/Verifier.h>
#include <cwrap/Fildes.h>
#include <stdex/Memory.h>
assert(loco::valid(graph));
}
+void transform_graph(loco::Graph *graph)
+{
+ std::vector<std::unique_ptr<moco::tf::Transform>> prepare;
+ std::vector<std::unique_ptr<moco::tf::Transform>> transforms;
+ std::vector<std::unique_ptr<moco::tf::Transform>> finalize;
+
+ // Transforms that run only once for preparation and finalization
+ {
+ // TODO add one time preparation when needed
+
+ // TODO add one time finalization when needed
+ }
+
+ // Transforms that run multiple times until there is no transform occured
+ {
+ // TODO add more TensorFlow related transformations
+ }
+
+ // Run preparation
+ for (auto &tr : prepare)
+ {
+ tr->run(graph);
+ }
+
+ bool changed;
+ do
+ {
+ changed = false;
+
+ for (auto &tr : transforms)
+ {
+ changed |= tr->run(graph);
+ }
+
+ } while (changed);
+
+ // Run finalize to cleanup temporary annotations
+ for (auto &tr : finalize)
+ {
+ tr->run(graph);
+ }
+
+ // validate graph
+ assert(loco::valid(graph));
+}
+
} // namespace
namespace moco
convert_graph(signature, tf_graph_def, graph.get());
+ transform_graph(graph.get());
+
return std::move(graph);
}
convert_graph(signature, tf_graph_def, graph.get());
+ transform_graph(graph.get());
+
return std::move(graph);
}