Merge "Implements RANDOM_MULTINOMIAL CTS/VTS tests."
This commit is contained in:
commit
fb50b69ae1
14 changed files with 49 additions and 48 deletions
|
@ -28,6 +28,7 @@ cc_library_static {
|
|||
"android.hardware.neuralnetworks@1.2",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_utils",
|
||||
],
|
||||
|
@ -55,6 +56,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.2",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_utils",
|
||||
"VtsHalNeuralnetworksTest_utils",
|
||||
|
|
|
@ -36,16 +36,17 @@ namespace neuralnetworks {
|
|||
namespace generated_tests {
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::test_helper::compare;
|
||||
using ::test_helper::expectMultinomialDistributionWithinTolerance;
|
||||
using ::test_helper::filter;
|
||||
using ::test_helper::Float32Operands;
|
||||
using ::test_helper::for_all;
|
||||
using ::test_helper::for_each;
|
||||
using ::test_helper::resize_accordingly;
|
||||
using ::test_helper::MixedTyped;
|
||||
using ::test_helper::MixedTypedExampleType;
|
||||
using ::test_helper::Float32Operands;
|
||||
using ::test_helper::Int32Operands;
|
||||
using ::test_helper::MixedTyped;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
using ::test_helper::Quant8Operands;
|
||||
using ::test_helper::compare;
|
||||
using ::test_helper::resize_accordingly;
|
||||
|
||||
template <typename T>
|
||||
void copy_back_(MixedTyped* dst, const std::vector<RequestArgument>& ra, char* src) {
|
||||
|
@ -66,7 +67,7 @@ void copy_back(MixedTyped* dst, const std::vector<RequestArgument>& ra, char* sr
|
|||
// Top level driver for models and examples generated by test_generator.py
|
||||
// Test driver for those generated from ml/nn/runtime/test/spec
|
||||
void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool(int)> is_ignored,
|
||||
const std::vector<MixedTypedExampleType>& examples, float fpAtol = 1e-5f,
|
||||
const std::vector<MixedTypedExample>& examples, float fpAtol = 1e-5f,
|
||||
float fpRtol = 1e-5f) {
|
||||
const uint32_t INPUT = 0;
|
||||
const uint32_t OUTPUT = 1;
|
||||
|
@ -75,8 +76,8 @@ void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool
|
|||
for (auto& example : examples) {
|
||||
SCOPED_TRACE(example_no++);
|
||||
|
||||
const MixedTyped& inputs = example.first;
|
||||
const MixedTyped& golden = example.second;
|
||||
const MixedTyped& inputs = example.operands.first;
|
||||
const MixedTyped& golden = example.operands.second;
|
||||
|
||||
std::vector<RequestArgument> inputs_info, outputs_info;
|
||||
uint32_t inputSize = 0, outputSize = 0;
|
||||
|
@ -176,12 +177,15 @@ void EvaluatePreparedModel(sp<IPreparedModel>& preparedModel, std::function<bool
|
|||
|
||||
// We want "close-enough" results for float
|
||||
compare(filtered_golden, filtered_test, fpAtol, fpRtol);
|
||||
|
||||
if (example.expectedMultinomialDistributionTolerance > 0) {
|
||||
expectMultinomialDistributionWithinTolerance(test, example);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Execute(const sp<V1_0::IDevice>& device, std::function<V1_0::Model(void)> create_model,
|
||||
std::function<bool(int)> is_ignored,
|
||||
const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples) {
|
||||
V1_0::Model model = create_model();
|
||||
|
||||
// see if service can handle model
|
||||
|
@ -225,8 +229,7 @@ void Execute(const sp<V1_0::IDevice>& device, std::function<V1_0::Model(void)> c
|
|||
}
|
||||
|
||||
void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> create_model,
|
||||
std::function<bool(int)> is_ignored,
|
||||
const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples) {
|
||||
V1_1::Model model = create_model();
|
||||
|
||||
// see if service can handle model
|
||||
|
@ -277,8 +280,7 @@ void Execute(const sp<V1_1::IDevice>& device, std::function<V1_1::Model(void)> c
|
|||
|
||||
// TODO: Reduce code duplication.
|
||||
void Execute(const sp<V1_2::IDevice>& device, std::function<V1_2::Model(void)> create_model,
|
||||
std::function<bool(int)> is_ignored,
|
||||
const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::function<bool(int)> is_ignored, const std::vector<MixedTypedExample>& examples) {
|
||||
V1_2::Model model = create_model();
|
||||
|
||||
// see if service can handle model
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace hardware {
|
|||
namespace neuralnetworks {
|
||||
|
||||
namespace generated_tests {
|
||||
using ::test_helper::MixedTypedExampleType;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
extern void Execute(const sp<V1_0::IDevice>&, std::function<V1_0::Model(void)>,
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExampleType>&);
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
|
||||
} // namespace generated_tests
|
||||
|
||||
namespace V1_0 {
|
||||
|
@ -43,9 +43,7 @@ namespace functional {
|
|||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::android::nn::allocateSharedMemory;
|
||||
|
||||
// Mixed-typed examples
|
||||
typedef test_helper::MixedTypedExampleType MixedTypedExample;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
|
||||
// in frameworks/ml/nn/runtime/tests/generated/
|
||||
#include "all_generated_V1_0_vts_tests.cpp"
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace V1_0 {
|
|||
namespace vts {
|
||||
namespace functional {
|
||||
|
||||
using MixedTypedExample = test_helper::MixedTypedExampleType;
|
||||
using MixedTypedExample = test_helper::MixedTypedExample;
|
||||
|
||||
#define FOR_EACH_TEST_MODEL(FN) \
|
||||
FN(add_broadcast_quant8) \
|
||||
|
|
|
@ -36,9 +36,9 @@ namespace functional {
|
|||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::android::hidl::memory::V1_0::IMemory;
|
||||
using test_helper::MixedTyped;
|
||||
using test_helper::MixedTypedExampleType;
|
||||
using test_helper::for_all;
|
||||
using test_helper::MixedTyped;
|
||||
using test_helper::MixedTypedExample;
|
||||
|
||||
///////////////////////// UTILITY FUNCTIONS /////////////////////////
|
||||
|
||||
|
@ -151,15 +151,15 @@ static void removeOutputTest(const sp<IPreparedModel>& preparedModel, const Requ
|
|||
|
||||
///////////////////////////// ENTRY POINT //////////////////////////////////
|
||||
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples) {
|
||||
const uint32_t INPUT = 0;
|
||||
const uint32_t OUTPUT = 1;
|
||||
|
||||
std::vector<Request> requests;
|
||||
|
||||
for (auto& example : examples) {
|
||||
const MixedTyped& inputs = example.first;
|
||||
const MixedTyped& outputs = example.second;
|
||||
for (const MixedTypedExample& example : examples) {
|
||||
const MixedTyped& inputs = example.operands.first;
|
||||
const MixedTyped& outputs = example.operands.second;
|
||||
|
||||
std::vector<RequestArgument> inputs_info, outputs_info;
|
||||
uint32_t inputSize = 0, outputSize = 0;
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace vts {
|
|||
namespace functional {
|
||||
|
||||
// forward declarations
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples);
|
||||
std::vector<Request> createRequests(const std::vector<::test_helper::MixedTypedExample>& examples);
|
||||
|
||||
// generate validation tests
|
||||
#define VTS_CURRENT_TEST_CASE(TestName) \
|
||||
|
|
|
@ -31,6 +31,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.2",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_utils",
|
||||
"VtsHalNeuralnetworksTest_utils",
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace hardware {
|
|||
namespace neuralnetworks {
|
||||
|
||||
namespace generated_tests {
|
||||
using ::test_helper::MixedTypedExampleType;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
extern void Execute(const sp<V1_1::IDevice>&, std::function<V1_1::Model(void)>,
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExampleType>&);
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
|
||||
} // namespace generated_tests
|
||||
|
||||
namespace V1_1 {
|
||||
|
@ -43,9 +43,7 @@ namespace functional {
|
|||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::android::nn::allocateSharedMemory;
|
||||
|
||||
// Mixed-typed examples
|
||||
typedef generated_tests::MixedTypedExampleType MixedTypedExample;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
|
||||
// in frameworks/ml/nn/runtime/tests/generated/
|
||||
#include "all_generated_V1_0_vts_tests.cpp"
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace V1_1 {
|
|||
namespace vts {
|
||||
namespace functional {
|
||||
|
||||
using MixedTypedExample = test_helper::MixedTypedExampleType;
|
||||
using MixedTypedExample = test_helper::MixedTypedExample;
|
||||
|
||||
#define FOR_EACH_TEST_MODEL(FN) \
|
||||
FN(add) \
|
||||
|
|
|
@ -36,9 +36,9 @@ namespace functional {
|
|||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::android::hidl::memory::V1_0::IMemory;
|
||||
using test_helper::MixedTyped;
|
||||
using test_helper::MixedTypedExampleType;
|
||||
using test_helper::for_all;
|
||||
using test_helper::MixedTyped;
|
||||
using test_helper::MixedTypedExample;
|
||||
|
||||
///////////////////////// UTILITY FUNCTIONS /////////////////////////
|
||||
|
||||
|
@ -152,15 +152,15 @@ static void removeOutputTest(const sp<IPreparedModel>& preparedModel, const Requ
|
|||
|
||||
///////////////////////////// ENTRY POINT //////////////////////////////////
|
||||
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples) {
|
||||
const uint32_t INPUT = 0;
|
||||
const uint32_t OUTPUT = 1;
|
||||
|
||||
std::vector<Request> requests;
|
||||
|
||||
for (auto& example : examples) {
|
||||
const MixedTyped& inputs = example.first;
|
||||
const MixedTyped& outputs = example.second;
|
||||
const MixedTyped& inputs = example.operands.first;
|
||||
const MixedTyped& outputs = example.operands.second;
|
||||
|
||||
std::vector<RequestArgument> inputs_info, outputs_info;
|
||||
uint32_t inputSize = 0, outputSize = 0;
|
||||
|
|
|
@ -31,6 +31,7 @@ cc_test {
|
|||
"android.hardware.neuralnetworks@1.2",
|
||||
"android.hidl.allocator@1.0",
|
||||
"android.hidl.memory@1.0",
|
||||
"libgmock",
|
||||
"libhidlmemory",
|
||||
"libneuralnetworks_utils",
|
||||
"VtsHalNeuralnetworksTest_utils",
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace hardware {
|
|||
namespace neuralnetworks {
|
||||
|
||||
namespace generated_tests {
|
||||
using ::test_helper::MixedTypedExampleType;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
extern void Execute(const sp<V1_2::IDevice>&, std::function<V1_2::Model(void)>,
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExampleType>&);
|
||||
std::function<bool(int)>, const std::vector<MixedTypedExample>&);
|
||||
} // namespace generated_tests
|
||||
|
||||
namespace V1_2 {
|
||||
|
@ -43,9 +43,7 @@ namespace functional {
|
|||
using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
|
||||
using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
|
||||
using ::android::nn::allocateSharedMemory;
|
||||
|
||||
// Mixed-typed examples
|
||||
typedef generated_tests::MixedTypedExampleType MixedTypedExample;
|
||||
using ::test_helper::MixedTypedExample;
|
||||
|
||||
// in frameworks/ml/nn/runtime/tests/generated/
|
||||
#include "all_generated_V1_0_vts_tests.cpp"
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace V1_2 {
|
|||
namespace vts {
|
||||
namespace functional {
|
||||
|
||||
using MixedTypedExample = test_helper::MixedTypedExampleType;
|
||||
using MixedTypedExample = test_helper::MixedTypedExample;
|
||||
|
||||
#define FOR_EACH_TEST_MODEL(FN) \
|
||||
FN(add) \
|
||||
|
@ -243,6 +243,7 @@ using MixedTypedExample = test_helper::MixedTypedExampleType;
|
|||
FN(pad_float_1) \
|
||||
FN(pad_float_1_relaxed) \
|
||||
FN(pad_relaxed) \
|
||||
FN(random_multinomial) \
|
||||
FN(relu1_float_1) \
|
||||
FN(relu1_float_1_relaxed) \
|
||||
FN(relu1_float_2) \
|
||||
|
|
|
@ -38,7 +38,7 @@ using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCa
|
|||
using ::android::hidl::memory::V1_0::IMemory;
|
||||
using test_helper::for_all;
|
||||
using test_helper::MixedTyped;
|
||||
using test_helper::MixedTypedExampleType;
|
||||
using test_helper::MixedTypedExample;
|
||||
|
||||
///////////////////////// UTILITY FUNCTIONS /////////////////////////
|
||||
|
||||
|
@ -152,15 +152,15 @@ static void removeOutputTest(const sp<IPreparedModel>& preparedModel, const Requ
|
|||
|
||||
///////////////////////////// ENTRY POINT //////////////////////////////////
|
||||
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExampleType>& examples) {
|
||||
std::vector<Request> createRequests(const std::vector<MixedTypedExample>& examples) {
|
||||
const uint32_t INPUT = 0;
|
||||
const uint32_t OUTPUT = 1;
|
||||
|
||||
std::vector<Request> requests;
|
||||
|
||||
for (auto& example : examples) {
|
||||
const MixedTyped& inputs = example.first;
|
||||
const MixedTyped& outputs = example.second;
|
||||
const MixedTyped& inputs = example.operands.first;
|
||||
const MixedTyped& outputs = example.operands.second;
|
||||
|
||||
std::vector<RequestArgument> inputs_info, outputs_info;
|
||||
uint32_t inputSize = 0, outputSize = 0;
|
||||
|
|
Loading…
Reference in a new issue