summaryrefslogtreecommitdiff
path: root/nn/runtime/test/TestGenerated.cpp
diff options
context:
space:
mode:
authorDavid Gross <dgross@google.com>2017-12-04 11:29:28 -0800
committerDavid Gross <dgross@google.com>2017-12-04 11:32:27 -0800
commit663155d58ca1e1eb42e01495e236258e0c00d40f (patch)
tree2e7ae7029cb722c01b33ea481f8a3af02dd3276e /nn/runtime/test/TestGenerated.cpp
parent4cb4fa2fe863a8f404c0448da160dd5bb4187db4 (diff)
downloadml-663155d58ca1e1eb42e01495e236258e0c00d40f.tar.gz
Add ::android::nn::graphDump() method for graph visualization.
Call this method to write a representation of a model in Graphviz (.dot) format. Test: nn/runtime/test Change-Id: If999e67c9501ae3ccadb8a62ec0cdc8b1d379253
Diffstat (limited to 'nn/runtime/test/TestGenerated.cpp')
-rw-r--r--nn/runtime/test/TestGenerated.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/nn/runtime/test/TestGenerated.cpp b/nn/runtime/test/TestGenerated.cpp
index f6677d91d..15c6ea164 100644
--- a/nn/runtime/test/TestGenerated.cpp
+++ b/nn/runtime/test/TestGenerated.cpp
@@ -16,6 +16,7 @@
// Top level driver for models and examples generated by test_generator.py
+#include "Bridge.h"
#include "NeuralNetworksWrapper.h"
#include "TestHarness.h"
@@ -26,9 +27,21 @@
#include <iostream>
#include <map>
+// Uncomment the following line to generate DOT graphs.
+//
+// #define GRAPH GRAPH
+
namespace generated_tests {
using namespace android::nn::wrapper;
+void graphDump([[maybe_unused]] const char* name, [[maybe_unused]] const Model& model) {
+#ifdef GRAPH
+ ::android::nn::bridge_tests::graphDump(
+ name,
+ reinterpret_cast<const ::android::nn::ModelBuilder*>(model.getHandle()));
+#endif
+}
+
template <typename T>
static void print(std::ostream& os, const MixedTyped& test) {
// dump T-typed inputs
@@ -55,6 +68,7 @@ static void execute(std::function<void(Model*)> createModel,
Model model;
createModel(&model);
model.finish();
+ graphDump("", model);
bool dumpToFile = !dumpFile.empty();
std::ofstream s;
@@ -123,4 +137,3 @@ class GeneratedTests : public ::testing::Test {
using namespace generated_tests;
#include "generated/all_generated_tests.cpp"
// End of testcases generated from runtime/test/specs/*.mod.py
-