forked from Samsung/ONE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onert/lib] Move RandomTestRunner class (Samsung#1839)
Introduce RandomTestRunner.cpp/h files and move RandomTestRunner class from Diff.cpp/h Signed-off-by: Hyeongseok Oh <[email protected]>
- Loading branch information
Showing
5 changed files
with
457 additions
and
395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file RandomTestRunner.h | ||
* @brief This file contains class for random input testing | ||
*/ | ||
|
||
#ifndef __NNFW_TFLITE_RANDOM_TEST_RUNNER_H__ | ||
#define __NNFW_TFLITE_RANDOM_TEST_RUNNER_H__ | ||
|
||
#include "tflite/interp/Builder.h" | ||
|
||
#include <misc/RandomGenerator.h> | ||
|
||
namespace nnfw | ||
{ | ||
namespace tflite | ||
{ | ||
|
||
/** | ||
* @brief Structure for NNAPI correctness test | ||
*/ | ||
struct RandomTestParam | ||
{ | ||
int verbose; //!< Verbosity of debug information | ||
int tolerance; //!< Torlerance of value difference | ||
int tensor_logging = 0; //!< Save logging to a file if not 0 | ||
std::string log_path = ""; //!< Path of log file, meaningful only when tensor_logging is 1 | ||
}; | ||
|
||
/** | ||
* @brief Class to define Random test runner | ||
*/ | ||
class RandomTestRunner | ||
{ | ||
public: | ||
/** | ||
* @brief Construct a new RandomTestRunner object | ||
* @param[in] seed Random seed value | ||
* @param[in] param RandomTestParam object for test runner | ||
* @param[in] quantization TfLiteQuantizationParams type to represent quantization value | ||
*/ | ||
RandomTestRunner(uint32_t seed, const RandomTestParam ¶m) | ||
: _randgen{seed, 0.0f, 2.0f}, _param{param} | ||
{ | ||
// DO NOTHING | ||
} | ||
|
||
public: | ||
/** | ||
* @brief Run the random test runner | ||
* @param[in] builder Interpreter Builder used to run | ||
* @return 0 if test succeeds, otherwise failure | ||
*/ | ||
int run(const nnfw::tflite::Builder &builder); | ||
|
||
public: | ||
/** | ||
* @brief Get RandomGenerator reference | ||
* @return RandomGenerator reference | ||
*/ | ||
nnfw::misc::RandomGenerator &generator() { return _randgen; }; | ||
|
||
private: | ||
nnfw::misc::RandomGenerator _randgen; | ||
const RandomTestParam _param; | ||
|
||
public: | ||
/** | ||
* @brief Create a RandomTestRunner object | ||
* @param[in] seed Random seed value | ||
* @return RandomGenerator object | ||
*/ | ||
static RandomTestRunner make(uint32_t seed); | ||
}; | ||
|
||
} // namespace tflite | ||
} // namespace nnfw | ||
|
||
#endif // __NNFW_TFLITE_RANDOM_TEST_RUNNER_H__ |
Oops, something went wrong.