From: 박종현/동작제어Lab(SR)/Staff Engineer/삼성전자 Date: Fri, 1 Jun 2018 03:17:53 +0000 (+0900) Subject: Flexible input generation switch for RandomTestRunner (#1495) X-Git-Tag: 0.2~738 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e0cc310cb7e4c5f43d4a81389cad6a840078ef05;p=platform%2Fcore%2Fml%2Fnnfw.git 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 --- 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;