Downgrade generated test harness for NDK libc++

NDK libc++ does not yet support full C++14. This CL replaced use of
std::get with type as well as auto lambda arguments with equivalent
C++11 constructs in the VTS test harness for NNAPI.

Test: VtsHalNeuralnetworksV1_0TargetTest
Bug: 63905942
Change-Id: If75e7c088e9221a70bcc47bc647e0dd7b045bfa1
diff --git a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
index db90ac2..4b8daec 100644
--- a/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
+++ b/neuralnetworks/1.0/vts/functional/GeneratedTestHarness.cpp
@@ -42,6 +42,24 @@
 using ::generated_tests::Float32Operands;
 using ::generated_tests::Int32Operands;
 using ::generated_tests::Quant8Operands;
+using ::generated_tests::compare;
+
+template <typename ty>
+void copy_back_(MixedTyped* dst, const std::vector<RequestArgument>& ra, char* src) {
+    MixedTyped& test = *dst;
+    for_each(test, [&ra, src](int index, std::vector<ty>& m) {
+        ASSERT_EQ(m.size(), ra[index].location.length / sizeof(ty));
+        char* begin = src + ra[index].location.offset;
+        memcpy(m.data(), begin, ra[index].location.length);
+    });
+}
+
+void copy_back(MixedTyped* dst, const std::vector<RequestArgument>& ra, char* src) {
+    copy_back_<float>(dst, ra, src);
+    copy_back_<int32_t>(dst, ra, src);
+    copy_back_<uint8_t>(dst, ra, src);
+}
+
 // Top level driver for models and examples generated by test_generator.py
 // Test driver for those generated from ml/nn/runtime/test/spec
 void Execute(const sp<IDevice>& device, std::function<Model(void)> create_model,
@@ -97,9 +115,7 @@
         MixedTyped test;  // holding test results
 
         // Go through all outputs, initialize RequestArgument descriptors
-        resize_accordingly<float>(golden, test);
-        resize_accordingly<int32_t>(golden, test);
-        resize_accordingly<uint8_t>(golden, test);
+        resize_accordingly(golden, test);
         for_all(golden, [&outputs_info, &outputSize](int index, auto, auto s) {
             if (outputs_info.size() <= static_cast<size_t>(index)) outputs_info.resize(index + 1);
             RequestArgument arg = {
@@ -156,40 +172,16 @@
 
         // validate results
         outputMemory->read();
-#define COPY_BACK(ty)                                                              \
-    for_each<ty>(test, [&outputs_info, outputPtr](int index, std::vector<ty>& m) { \
-        RequestArgument& i = outputs_info[index];                                  \
-        ASSERT_EQ(m.size(), i.location.length / sizeof(ty));                       \
-        char* begin = outputPtr + i.location.offset;                               \
-        memcpy(m.data(), begin, i.location.length);                                \
-    });
-        COPY_BACK(float);
-        COPY_BACK(int32_t);
-        COPY_BACK(uint8_t);
-#undef COPY_BACK
+        copy_back(&test, outputs_info, outputPtr);
         outputMemory->commit();
         // Filter out don't cares
         MixedTyped filtered_golden;
         MixedTyped filtered_test;
-        filter<float>(golden, &filtered_golden, is_ignored);
-        filter<float>(test, &filtered_test, is_ignored);
-        filter<int32_t>(golden, &filtered_golden, is_ignored);
-        filter<int32_t>(test, &filtered_test, is_ignored);
-        filter<uint8_t>(golden, &filtered_golden, is_ignored);
-        filter<uint8_t>(test, &filtered_test, is_ignored);
+        filter(golden, &filtered_golden, is_ignored);
+        filter(test, &filtered_test, is_ignored);
 
         // We want "close-enough" results for float
-        for_each<float>(filtered_golden, [&filtered_test](int index, auto& golden_float) {
-            auto& test_float_operands = std::get<Float32Operands>(filtered_test);
-            auto& test_float = test_float_operands[index];
-            for (unsigned int i = 0; i < golden_float.size(); i++) {
-                SCOPED_TRACE(i);
-                EXPECT_NEAR(golden_float[i], test_float[i], 1.e-5);
-            }
-        });
-        EXPECT_EQ(std::get<Int32Operands>(filtered_golden), std::get<Int32Operands>(filtered_test));
-        EXPECT_EQ(std::get<Quant8Operands>(filtered_golden),
-                  std::get<Quant8Operands>(filtered_test));
+        compare(filtered_golden, filtered_test);
     }
 }