Enable the kTfLiteUInt8 of the input operands in RandomTestRunner to be random value...
author장지섭/동작제어Lab(SR)/Engineer/삼성전자 <jiseob.jang@samsung.com>
Fri, 6 Jul 2018 06:45:02 +0000 (15:45 +0900)
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>
Fri, 6 Jul 2018 06:45:02 +0000 (15:45 +0900)
This commit enables the kTfLiteUInt8 of the input operands in RandomTestRunner to be random value.

Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
libs/support/tflite/src/Diff.cpp

index 50e6843..fca2e68 100644 (file)
@@ -309,12 +309,16 @@ int RandomTestRunner::run(const nnfw::support::tflite::interp::Builder &builder)
 
     assert(tfl_interp_view.shape() == nnapi_view.shape());
 
-    uint8_t value = 0;
+    auto fp = static_cast<uint8_t (RandomGenerator::*)(const ::nnfw::util::tensor::Shape &,
+                                                       const ::nnfw::util::tensor::Index &)>(
+        &RandomGenerator::generate<uint8_t>);
+    const nnfw::util::tensor::Object<uint8_t> data(tfl_interp_view.shape(),
+                                                   std::bind(fp, _randgen, _1, _2));
+    assert(tfl_interp_view.shape() == data.shape());
 
     nnfw::util::tensor::iterate(tfl_interp_view.shape())
         << [&](const nnfw::util::tensor::Index &ind) {
-             // TODO Generate random values
-             value = (value + 1) & 0xFF;
+             const auto value = data.at(ind);
 
              tfl_interp_view.at(ind) = value;
              nnapi_view.at(ind) = value;