ONE - On-device Neural Engine
Loading...
Searching...
No Matches
onert_micro::execute::testing Namespace Reference

Functions

::testing::Matcher< std::vector< float > > FloatArrayNear (const std::vector< float > &values, float max_abs_error=1.0e-5f)
 
template<typename T , typename U = T>
std::vector< U > checkKernel (uint32_t num_inputs, onert_micro::test_model::TestDataBase< T, U > *test_data_base)
 
void checkNEGSISOKernel (onert_micro::test_model::NegTestDataBase *test_data_base)
 

Function Documentation

◆ checkKernel()

template<typename T , typename U = T>
std::vector< U > onert_micro::execute::testing::checkKernel ( uint32_t  num_inputs,
onert_micro::test_model::TestDataBase< T, U > *  test_data_base 
)

Definition at line 40 of file OMTestUtils.h.

42{
45
46 interpreter.importModel(reinterpret_cast<const char *>(test_data_base->get_model_ptr()), config);
47
48 assert(num_inputs == interpreter.getNumberOfInputs());
49
50 interpreter.reset();
51 interpreter.allocateInputs();
52
53 for (uint32_t i = 0; i < num_inputs; ++i)
54 {
55 T *input_data = reinterpret_cast<T *>(interpreter.getInputDataAt(i));
56
57 // Set input data
58 {
59 std::copy(test_data_base->get_input_data_by_index(i).begin(),
60 test_data_base->get_input_data_by_index(i).end(), input_data);
61 }
62 }
63
64 interpreter.run(config);
65
66 U *output_data = reinterpret_cast<U *>(interpreter.getOutputDataAt(0));
67 const size_t num_elements = interpreter.getOutputSizeAt(0);
68 std::vector<U> output_data_vector(output_data, output_data + num_elements);
69 return output_data_vector;
70}
virtual const std::vector< T > & get_input_data_by_index(int i)=0
virtual const unsigned char * get_model_ptr()=0

References onert_micro::test_model::TestDataBase< T, U >::get_input_data_by_index(), and onert_micro::test_model::TestDataBase< T, U >::get_model_ptr().

◆ checkNEGSISOKernel()

void onert_micro::execute::testing::checkNEGSISOKernel ( onert_micro::test_model::NegTestDataBase test_data_base)

Definition at line 38 of file OMTestUtils.cpp.

39{
42
43 interpreter.importModel(reinterpret_cast<const char *>(test_data_base->get_model_ptr()), config);
44}
virtual const unsigned char * get_model_ptr()=0

References onert_micro::test_model::NegTestDataBase::get_model_ptr().

◆ FloatArrayNear()

Matcher< std::vector< float > > onert_micro::execute::testing::FloatArrayNear ( const std::vector< float > &  values,
float  max_abs_error = 1.0e-5f 
)

Definition at line 26 of file OMTestUtils.cpp.

28{
29 std::vector<Matcher<float>> matchers;
30 matchers.reserve(values.size());
31 for (const float v : values)
32 {
33 matchers.emplace_back(FloatNear(v, max_abs_error));
34 }
35 return ElementsAreArray(matchers);
36}