teflon/tests: Test all models in /models

It was becoming quite tedious to add models to testing.

This will also make it easier to locally test with non-redistributable
models.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34481>
This commit is contained in:
Tomeu Vizoso 2024-11-25 11:08:45 +01:00 committed by Marge Bot
parent 68200ac961
commit b3746305ea
290 changed files with 104 additions and 166 deletions

View file

@ -8,7 +8,7 @@ Add.Op/input_size_5_weight_size_5_input_channels_32_output_channels_256_stride_2
Add.Op/input_size_80_weight_size_3_input_channels_32_output_channels_120_stride_1_padding_same_1_is_signed_0,Fail
Add.Op/input_size_80_weight_size_5_input_channels_32_output_channels_256_stride_1_padding_same_1_is_signed_0,Fail
MobileDetParam.Op/mobiledet082,Fail
MobileDet.Whole,Fail
Models.Op/mobiledet_082,Fail
Models.Op/mobiledet_ssdlite_mobiledet_coco_qat_postprocess,Fail
YoloX.Whole,Fail
Models.Op/yolox_yolox,Fail

View file

@ -3,26 +3,40 @@ Add.Op/input_size_8_weight_size_3_input_channels_32_output_channels_120_stride_1
Add.Op/input_size_8_weight_size_5_input_channels_32_output_channels_256_stride_1_padding_same_1_is_signed_0
# These tests below (adds) aren't well constructed and thus fail in TF
MobileDetParam.Op/mobiledet008
MobileDetParam.Op/mobiledet011
MobileDetParam.Op/mobiledet014
MobileDetParam.Op/mobiledet019
MobileDetParam.Op/mobiledet022
MobileDetParam.Op/mobiledet025
MobileDetParam.Op/mobiledet032
MobileDetParam.Op/mobiledet035
MobileDetParam.Op/mobiledet038
MobileDetParam.Op/mobiledet045
MobileDetParam.Op/mobiledet049
MobileDetParam.Op/mobiledet053
MobileDetParam.Op/mobiledet060
MobileDetParam.Op/mobiledet064
MobileDetParam.Op/mobiledet068
YoloXParam.Op/yolox011
YoloXParam.Op/yolox020
YoloXParam.Op/yolox023
YoloXParam.Op/yolox026
YoloXParam.Op/yolox035
YoloXParam.Op/yolox038
YoloXParam.Op/yolox041
Models.Op/mobiledet_008
Models.Op/mobiledet_011
Models.Op/mobiledet_014
Models.Op/mobiledet_019
Models.Op/mobiledet_022
Models.Op/mobiledet_025
Models.Op/mobiledet_032
Models.Op/mobiledet_035
Models.Op/mobiledet_038
Models.Op/mobiledet_045
Models.Op/mobiledet_049
Models.Op/mobiledet_053
Models.Op/mobiledet_060
Models.Op/mobiledet_064
Models.Op/mobiledet_068
Models.Op/yolox_011
Models.Op/yolox_020
Models.Op/yolox_023
Models.Op/yolox_026
Models.Op/yolox_035
Models.Op/yolox_038
Models.Op/yolox_041
# These tests below (splits) aren't well constructed and thus fail in TF
Models.Op/detect_003
Models.Op/detect_012
Models.Op/detect_020
Models.Op/detect_029
Models.Op/detect_037
Models.Op/detect_046
Models.Op/detect_054
Models.Op/detect_062
Models.Op/detect_070
Models.Op/detect_078
Models.Op/detect_086
Models.Op/detect_095
Models.Op/detect_103

View file

@ -11,30 +11,30 @@ Add.Op/input_size_8_weight_size_5_input_channels_1_output_channels_256_stride_2_
# No idea why this one is failing, needs investigation.
# It takes a long time, so better skip for now.
MobileDet.Whole
Models.Op/mobiledet_ssdlite_mobiledet_coco_qat_postprocess
# These tests below (adds) aren't well constructed and thus fail in TF
MobileDetParam.Op/mobiledet008
MobileDetParam.Op/mobiledet011
MobileDetParam.Op/mobiledet014
MobileDetParam.Op/mobiledet019
MobileDetParam.Op/mobiledet022
MobileDetParam.Op/mobiledet025
MobileDetParam.Op/mobiledet032
MobileDetParam.Op/mobiledet035
MobileDetParam.Op/mobiledet038
MobileDetParam.Op/mobiledet045
MobileDetParam.Op/mobiledet049
MobileDetParam.Op/mobiledet053
MobileDetParam.Op/mobiledet060
MobileDetParam.Op/mobiledet064
MobileDetParam.Op/mobiledet068
YoloXParam.Op/yolox011
YoloXParam.Op/yolox020
YoloXParam.Op/yolox023
YoloXParam.Op/yolox026
YoloXParam.Op/yolox035
YoloXParam.Op/yolox038
YoloXParam.Op/yolox041
Models.Op/mobiledet_008
Models.Op/mobiledet_011
Models.Op/mobiledet_014
Models.Op/mobiledet_019
Models.Op/mobiledet_022
Models.Op/mobiledet_025
Models.Op/mobiledet_032
Models.Op/mobiledet_035
Models.Op/mobiledet_038
Models.Op/mobiledet_045
Models.Op/mobiledet_049
Models.Op/mobiledet_053
Models.Op/mobiledet_060
Models.Op/mobiledet_064
Models.Op/mobiledet_068
Models.Op/yolox_011
Models.Op/yolox_020
Models.Op/yolox_023
Models.Op/yolox_026
Models.Op/yolox_035
Models.Op/yolox_038
Models.Op/yolox_041
FullyConnected.Op/*

View file

@ -11,6 +11,9 @@
#include <xtensor/xrandom.hpp>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include "tensorflow/lite/c/c_api.h"
#include "test_executor.h"
@ -18,9 +21,7 @@
#define TEST_DEPTHWISE 1
#define TEST_ADD 1
#define TEST_FULLY_CONNECTED 1
#define TEST_MOBILENETV1 1
#define TEST_MOBILEDET 1
#define TEST_YOLOX 1
#define TEST_MODELS 1
#define TOLERANCE 2
@ -124,8 +125,13 @@ test_model_file(std::string file_name, unsigned tolerance, bool use_cache)
{
std::ostringstream cache_dir;
if (use_cache)
cache_dir << "/var/cache/teflon_tests/" << std::filesystem::path(file_name).stem().c_str();
if (use_cache) {
auto path = std::filesystem::path(file_name);
cache_dir << "/var/cache/teflon_tests/";
cache_dir << path.parent_path().filename().string();
cache_dir << "_";
cache_dir << path.stem().string();
}
set_seed(4);
@ -453,138 +459,56 @@ INSTANTIATE_TEST_SUITE_P(
#endif
#if TEST_MOBILENETV1
#if TEST_MODELS
class MobileNetV1 : public ::testing::Test {};
class Models : public testing::TestWithParam<std::string> {};
class MobileNetV1Param : public testing::TestWithParam<int> {};
TEST(MobileNetV1, Whole)
TEST_P(Models, Op)
{
std::ostringstream file_path;
auto test_name = GetParam();
test_name.replace(test_name.find("_"), 1, "/");
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/mobilenet_v1_1.0_224_quant.tflite";
file_path << getenv("TEFLON_TEST_DATA") << "/models/" << test_name << ".tflite";
test_model_file(file_path.str(), TOLERANCE, true);
}
TEST_P(MobileNetV1Param, Op)
std::vector<std::string>
get_model_files(void)
{
std::ostringstream file_path;
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/mb-" << std::setfill('0') << std::setw(3) << GetParam() << ".tflite";
std::stringstream dir;
dir << getenv("TEFLON_TEST_DATA") << "/models";
test_model_file(file_path.str(), TOLERANCE, true);
std::vector<std::string> paths;
std::filesystem::recursive_directory_iterator b(dir.str());
for (auto const& f : b) {
if (f.path().extension() != ".tflite")
continue;
std::stringstream path;
path << f.path().parent_path().filename().string();
path << "_" << f.path().stem().string();
paths.push_back(path.str());
}
std::sort(paths.begin(), paths.end());
return paths;
}
static inline std::string
MobileNetV1TestCaseName(
const testing::TestParamInfo<int> &info)
ModelsTestCaseName(
const testing::TestParamInfo<std::string> &info)
{
std::string name = "";
std::string param = std::to_string(info.param);
name += "mb";
name += std::string(3 - param.length(), '0');
name += param;
return name;
return info.param;
}
INSTANTIATE_TEST_SUITE_P(
, MobileNetV1Param,
::testing::Range(0, 31),
MobileNetV1TestCaseName);
#endif
#if TEST_MOBILEDET
class MobileDet : public ::testing::Test {};
class MobileDetParam : public testing::TestWithParam<int> {};
TEST(MobileDet, Whole)
{
std::ostringstream file_path;
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/ssdlite_mobiledet_coco_qat_postprocess.tflite";
test_model_file(file_path.str(), TOLERANCE, true);
}
TEST_P(MobileDetParam, Op)
{
std::ostringstream file_path;
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/mobiledet-" << std::setfill('0') << std::setw(3) << GetParam() << ".tflite";
test_model_file(file_path.str(), TOLERANCE, true);
}
static inline std::string
MobileDetTestCaseName(
const testing::TestParamInfo<int> &info)
{
std::string name = "";
std::string param = std::to_string(info.param);
name += "mobiledet";
name += std::string(3 - param.length(), '0');
name += param;
return name;
}
INSTANTIATE_TEST_SUITE_P(
, MobileDetParam,
::testing::Range(0, 124),
MobileDetTestCaseName);
#endif
#if TEST_YOLOX
class YoloX : public ::testing::Test {};
class YoloXParam : public testing::TestWithParam<int> {};
TEST(YoloX, Whole)
{
std::ostringstream file_path;
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/yolox.tflite";
test_model_file(file_path.str(), TOLERANCE, true);
}
TEST_P(YoloXParam, Op)
{
std::ostringstream file_path;
assert(getenv("TEFLON_TEST_DATA"));
file_path << getenv("TEFLON_TEST_DATA") << "/yolox-" << std::setfill('0') << std::setw(3) << GetParam() << ".tflite";
test_model_file(file_path.str(), TOLERANCE, true);
}
static inline std::string
YoloXTestCaseName(
const testing::TestParamInfo<int> &info)
{
std::string name = "";
std::string param = std::to_string(info.param);
name += "yolox";
name += std::string(3 - param.length(), '0');
name += param;
return name;
}
INSTANTIATE_TEST_SUITE_P(
, YoloXParam,
::testing::Range(0, 128),
YoloXTestCaseName);
, Models,
::testing::ValuesIn(get_model_files()),
ModelsTestCaseName);
#endif

Some files were not shown because too many files have changed in this diff Show more