diff options
author | Xusong Wang <xusongw@google.com> | 2019-08-02 14:32:38 -0700 |
---|---|---|
committer | Xusong Wang <xusongw@google.com> | 2019-08-08 18:51:41 -0700 |
commit | 36abecb437410d49c536a8686ae002471c3078b3 (patch) | |
tree | 252e3e86716a13de285f5de8cc1ffa546289917a /nn/runtime/test/TestGenerated.cpp | |
parent | 37ec6b9768ae5437740a5438a7f1cab7b487ee29 (diff) | |
download | ml-36abecb437410d49c536a8686ae002471c3078b3.tar.gz |
Remove the slicing tool.
This tool is broken and nobody is actively using it. Remove it to
simplify the refactoring process of test generator.
Bug: 137774931
Test: regenerate tests, nothing changed
Test: NNT_static
Change-Id: I364f45f2775eeb266ff4fd678066f36bc18564a4
Diffstat (limited to 'nn/runtime/test/TestGenerated.cpp')
-rw-r--r-- | nn/runtime/test/TestGenerated.cpp | 79 |
1 files changed, 11 insertions, 68 deletions
diff --git a/nn/runtime/test/TestGenerated.cpp b/nn/runtime/test/TestGenerated.cpp index 5f663e3b0..009fbc8ca 100644 --- a/nn/runtime/test/TestGenerated.cpp +++ b/nn/runtime/test/TestGenerated.cpp @@ -27,6 +27,7 @@ #include <iostream> #include <map> #include <thread> +#include <vector> // Systrace is not available from CTS tests due to platform layering // constraints. We reuse the NNTEST_ONLY_PUBLIC_API flag, as that should also be @@ -43,46 +44,6 @@ namespace generated_tests { using namespace android::nn::test_wrapper; using namespace test_helper; -namespace { -template <typename T> -void print(std::ostream& os, const std::map<int, std::vector<T>>& test) { - // dump T-typed inputs - for_each<T>(test, [&os](int idx, const std::vector<T>& f) { - os << " aliased_output" << idx << ": ["; - for (size_t i = 0; i < f.size(); ++i) { - os << (i == 0 ? "" : ", ") << +f[i]; - } - os << "],\n"; - }); -} - -// Specialized for _Float16 because it requires explicit conversion. -template <> -void print<_Float16>(std::ostream& os, const std::map<int, std::vector<_Float16>>& test) { - for_each<_Float16>(test, [&os](int idx, const std::vector<_Float16>& f) { - os << " aliased_output" << idx << ": ["; - for (size_t i = 0; i < f.size(); ++i) { - os << (i == 0 ? "" : ", ") << +static_cast<float>(f[i]); - } - os << "],\n"; - }); -} - -void printAll(std::ostream& os, const MixedTyped& test) { - print(os, test.float32Operands); - print(os, test.int32Operands); - print(os, test.quant8AsymmOperands); - print(os, test.quant16SymmOperands); - print(os, test.float16Operands); - print(os, test.bool8Operands); - print(os, test.quant8ChannelOperands); - print(os, test.quant16AsymmOperands); - print(os, test.quant8SymmOperands); - static_assert(9 == MixedTyped::kNumTypes, - "Number of types in MixedTyped changed, but printAll function wasn't updated"); -} -} // namespace - std::optional<Compilation> GeneratedTests::compileModel(const Model* model) { NNTRACE_APP(NNTRACE_PHASE_COMPILATION, "compileModel"); if (mTestCompilationCaching) { @@ -112,15 +73,7 @@ std::optional<Compilation> GeneratedTests::compileModel(const Model* model) { void GeneratedTests::executeWithCompilation(const Model* model, Compilation* compilation, std::function<bool(int)> isIgnored, - std::vector<MixedTypedExample>& examples, - std::string dumpFile) { - bool dumpToFile = !dumpFile.empty(); - std::ofstream s; - if (dumpToFile) { - s.open(dumpFile, std::ofstream::trunc); - ASSERT_TRUE(s.is_open()); - } - + std::vector<MixedTypedExample>& examples) { int exampleNo = 0; float fpAtol = 1e-5f; float fpRtol = 5.0f * 1.1920928955078125e-7f; @@ -176,14 +129,6 @@ void GeneratedTests::executeWithCompilation(const Model* model, Compilation* com ASSERT_EQ(Result::NO_ERROR, execution.getOutputOperandDimensions(idx, &t)); }); - // Dump all outputs for the slicing tool - if (dumpToFile) { - s << "output" << exampleNo << " = {\n"; - printAll(s, test); - // all outputs are done - s << "}\n"; - } - // Filter out don't cares MixedTyped filteredGolden = filter(golden, isIgnored); MixedTyped filteredTest = filter(test, isIgnored); @@ -200,12 +145,12 @@ void GeneratedTests::executeWithCompilation(const Model* model, Compilation* com } void GeneratedTests::executeOnce(const Model* model, std::function<bool(int)> isIgnored, - std::vector<MixedTypedExample>& examples, std::string dumpFile) { + std::vector<MixedTypedExample>& examples) { NNTRACE_APP(NNTRACE_PHASE_OVERALL, "executeOnce"); std::optional<Compilation> compilation = compileModel(model); // Early return if compilation fails. The compilation result code is checked in compileModel. if (!compilation) return; - executeWithCompilation(model, &compilation.value(), isIgnored, examples, dumpFile); + executeWithCompilation(model, &compilation.value(), isIgnored, examples); } void GeneratedTests::executeMultithreadedOwnCompilation(const Model* model, @@ -215,7 +160,7 @@ void GeneratedTests::executeMultithreadedOwnCompilation(const Model* model, SCOPED_TRACE("MultithreadedOwnCompilation"); std::vector<std::thread> threads; for (int i = 0; i < 10; i++) { - threads.push_back(std::thread([&]() { executeOnce(model, isIgnored, examples, ""); })); + threads.push_back(std::thread([&]() { executeOnce(model, isIgnored, examples); })); } std::for_each(threads.begin(), threads.end(), [](std::thread& t) { t.join(); }); } @@ -231,7 +176,7 @@ void GeneratedTests::executeMultithreadedSharedCompilation( std::vector<std::thread> threads; for (int i = 0; i < 10; i++) { threads.push_back(std::thread([&]() { - executeWithCompilation(model, &compilation.value(), isIgnored, examples, ""); + executeWithCompilation(model, &compilation.value(), isIgnored, examples); })); } std::for_each(threads.begin(), threads.end(), [](std::thread& t) { t.join(); }); @@ -240,27 +185,25 @@ void GeneratedTests::executeMultithreadedSharedCompilation( // Test driver for those generated from ml/nn/runtime/test/spec void GeneratedTests::execute(std::function<void(Model*)> createModel, std::function<bool(int)> isIgnored, - std::vector<MixedTypedExample>& examples, - [[maybe_unused]] std::string dumpFile) { + std::vector<MixedTypedExample>& examples) { NNTRACE_APP(NNTRACE_PHASE_OVERALL, "execute"); Model model; createModel(&model); model.finish(); - auto executeInternal = [&model, &isIgnored, &examples, - this]([[maybe_unused]] std::string dumpFile) { + auto executeInternal = [&model, &isIgnored, &examples, this]() { SCOPED_TRACE("TestCompilationCaching = " + std::to_string(mTestCompilationCaching)); #ifndef NNTEST_MULTITHREADED - executeOnce(&model, isIgnored, examples, dumpFile); + executeOnce(&model, isIgnored, examples); #else // defined(NNTEST_MULTITHREADED) executeMultithreadedOwnCompilation(&model, isIgnored, examples); executeMultithreadedSharedCompilation(&model, isIgnored, examples); #endif // !defined(NNTEST_MULTITHREADED) }; mTestCompilationCaching = false; - executeInternal(dumpFile); + executeInternal(); if (!mExpectFailure) { mTestCompilationCaching = true; - executeInternal(""); + executeInternal(); } } |