diff options
author | David Gross <dgross@google.com> | 2017-12-04 11:29:28 -0800 |
---|---|---|
committer | David Gross <dgross@google.com> | 2017-12-04 11:32:27 -0800 |
commit | 663155d58ca1e1eb42e01495e236258e0c00d40f (patch) | |
tree | 2e7ae7029cb722c01b33ea481f8a3af02dd3276e /nn/runtime/test/TestPartitioningRandom.cpp | |
parent | 4cb4fa2fe863a8f404c0448da160dd5bb4187db4 (diff) | |
download | ml-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/TestPartitioningRandom.cpp')
-rw-r--r-- | nn/runtime/test/TestPartitioningRandom.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/nn/runtime/test/TestPartitioningRandom.cpp b/nn/runtime/test/TestPartitioningRandom.cpp index ed91a73b4..0ffea49b8 100644 --- a/nn/runtime/test/TestPartitioningRandom.cpp +++ b/nn/runtime/test/TestPartitioningRandom.cpp @@ -16,6 +16,7 @@ #undef NDEBUG +#include "Bridge.h" #include "CompilationBuilder.h" #include "Manager.h" #include "ModelBuilder.h" @@ -45,6 +46,10 @@ // // #define VERBOSE VERBOSE +// Uncomment the following line to generate graphs from models: +// +// #define GRAPH GRAPH + // We randomly generate tests (model + input data) at runtime, and verify // that we get the same results whether we do partitioned compilation/execution // or non partitioned compilation/execution. We perform a test as follows: @@ -331,6 +336,8 @@ public: static Signature getSignature(const HidlModel& model, const Operation& operation); protected: + void graphDump(const WrapperModel& model); + bool randBool() { return randUInt(2) == 1; } @@ -446,6 +453,14 @@ Signature RandomPartitioningTest::getSignature(const HidlModel& model, const Ope return Signature(operationType, value); } +void RandomPartitioningTest::graphDump([[maybe_unused]] const WrapperModel& model) { +#ifdef GRAPH + const std::string name = "Test-" + std::to_string(GetParam()); + nn::bridge_tests::graphDump(name.c_str(), + reinterpret_cast<const ModelBuilder*>(model.getHandle())); +#endif +} + class TestDriver : public SampleDriver { public: // Behaves like SampleDriver, except that it only supports @@ -857,6 +872,7 @@ TEST_P(RandomPartitioningTest, Test) { } #endif ASSERT_EQ(model.finish(), Result::NO_ERROR); + graphDump(model); // Non-partitioned compilation. TestCompilation c(&model); |