#include "Canonicalization/BiasAddCanonicalizer.h"
#include "Canonicalization/Conv2DCanonicalizer.h"
+#include "Dialect/TFDialect.h"
+#include "Dialect/TFNodes.h"
+
#include <stdex/Memory.h>
+namespace
+{
+
+/**
+ * @brief Return true if graph has TFDialect nodes
+ */
+bool has_tf_nodes(loco::Graph *g)
+{
+ auto active_nodes = loco::active_nodes(loco::output_nodes(g));
+ for (auto node : active_nodes)
+ {
+ if (node->dialect() == moco::tf::TFDialect::get())
+ {
+ if (moco::tf::get<moco::tf::Knob::CanonicalizeBiasAdd>())
+ {
+ auto tfnode = dynamic_cast<moco::tf::TFBiasAdd *>(node);
+ if (tfnode != nullptr)
+ return true;
+ }
+ if (moco::tf::get<moco::tf::Knob::CanonicalizeConv2D>())
+ {
+ auto tfnode = dynamic_cast<moco::tf::TFConv2D *>(node);
+ if (tfnode != nullptr)
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+} // namespace
+
namespace moco
{
namespace tf
moco::tf::PhaseRunner<moco::tf::PhaseStrategy::Saturate> phase_runner{g};
phase_runner.run(phase);
+
+ // Assert if graph has TF dialect nodes
+ assert(!has_tf_nodes(g));
}
} // namespace tf