From e0cc310cb7e4c5f43d4a81389cad6a840078ef05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 1 Jun 2018 12:17:53 +0900 Subject: [PATCH] Flexible input generation switch for RandomTestRunner (#1495) This commit revises RandomTestRunner to make it easy to extend supported input type. Signed-off-by: Jonghyun Park --- libs/support/tflite/src/Diff.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/libs/support/tflite/src/Diff.cpp b/libs/support/tflite/src/Diff.cpp index 8355fc3..f2a86c9 100644 --- a/libs/support/tflite/src/Diff.cpp +++ b/libs/support/tflite/src/Diff.cpp @@ -180,12 +180,7 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) assert(pure->inputs() == nnapi->inputs()); - // Fill IFM with random numbers - for (const auto id : pure->inputs()) - { - assert(pure->tensor(id)->type == nnapi->tensor(id)->type); - - // NOTE Float inputs are supported currently + auto floatgen = [&](int id, ::tflite::Interpreter *pure, ::tflite::Interpreter *nnapi) { assert(pure->tensor(id)->type == kTfLiteFloat32); assert(nnapi->tensor(id)->type == kTfLiteFloat32); @@ -204,6 +199,24 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder) pure_view.at(ind) = value; nnapi_view.at(ind) = value; }; + }; + + // Fill IFM with random numbers + for (const auto id : pure->inputs()) + { + assert(pure->tensor(id)->type == nnapi->tensor(id)->type); + switch (pure->tensor(id)->type) + { + case kTfLiteFloat32: + { + floatgen(id, pure.get(), nnapi.get()); + break; + } + default: + { + throw std::runtime_error{"Not supported input type"}; + } + } } std::cout << "[NNAPI TEST] Run T/F Lite Interpreter without NNAPI" << std::endl; -- 2.7.4