-
-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run default models in applications_performance test
- Loading branch information
Showing
1 changed file
with
185 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,189 @@ | ||
/* | ||
CUDA_VISIBLE_DEVICES='' python3.11 ../keras_export/generate_test_models.py exhaustive test_model_exhaustive.keras | ||
CUDA_VISIBLE_DEVICES='' python3.11 ../keras_export/convert_model.py test_model_exhaustive.keras test_model_exhaustive.json | ||
cat test_model_exhaustive.json | jq . > test_model_exhaustive.json.formatted.json | ||
subl test_model_exhaustive.json.formatted.json | ||
./applications_performance_d | ||
*/ | ||
// Copyright 2016, Tobias Hermann. | ||
// https://github.com/Dobiasd/frugally-deep | ||
// Distributed under the MIT License. | ||
// (See accompanying LICENSE file or at | ||
// https://opensource.org/licenses/MIT) | ||
|
||
#include "fdeep/fdeep.hpp" | ||
|
||
int main() | ||
{ | ||
fdeep::load_model("test_model_exhaustive.json"); | ||
} | ||
std::vector<std::string> model_paths = { | ||
// "convnextbase.json", | ||
// "convnextlarge.json", | ||
// "convnextsmall.json", | ||
// "convnexttiny.json", | ||
// "convnextxlarge.json", | ||
"densenet121.json", | ||
"densenet169.json", | ||
"densenet201.json", | ||
"efficientnetb0.json", | ||
"efficientnetb1.json", | ||
"efficientnetb2.json", | ||
"efficientnetb3.json", | ||
"efficientnetb4.json", | ||
"efficientnetb5.json", | ||
"efficientnetb6.json", | ||
"efficientnetb7.json", | ||
"efficientnetv2b0.json", | ||
"efficientnetv2b1.json", | ||
"efficientnetv2b2.json", | ||
"efficientnetv2b3.json", | ||
"efficientnetv2l.json", | ||
"efficientnetv2m.json", | ||
"efficientnetv2s.json", | ||
// "inceptionresnetv2.json", | ||
"inceptionv3.json", | ||
"mobilenet.json", | ||
"mobilenetv2.json", | ||
"nasnetlarge.json", | ||
"nasnetmobile.json", | ||
"resnet101.json", | ||
"resnet101v2.json", | ||
"resnet152.json", | ||
"resnet152v2.json", | ||
"resnet50.json", | ||
"resnet50v2.json", | ||
"vgg16.json", | ||
"vgg19.json", | ||
"xception.json" | ||
}; | ||
|
||
bool error = false; | ||
|
||
for (const auto& model_path : model_paths) | ||
{ | ||
std::cout << "----" << std::endl; | ||
std::cout << model_path << std::endl; | ||
#ifdef NDEBUG | ||
try | ||
{ | ||
const auto model = fdeep::load_model(model_path, true); | ||
const std::size_t warm_up_runs = 3; | ||
const std::size_t test_runs = 5; | ||
for (std::size_t i = 0; i < warm_up_runs; ++i) | ||
{ | ||
const double duration = model.test_speed(); | ||
std::cout << "Forward pass took " | ||
<< duration << " s." << std::endl; | ||
} | ||
double duration_sum = 0; | ||
std::cout << "Starting performance measurements." << std::endl; | ||
for (std::size_t i = 0; i < test_runs; ++i) | ||
{ | ||
const double duration = model.test_speed(); | ||
duration_sum += duration; | ||
std::cout << "Forward pass took " | ||
<< duration << " s." << std::endl; | ||
} | ||
const double duration_avg = | ||
duration_sum / static_cast<double>(test_runs); | ||
std::cout << "Forward pass took " | ||
<< duration_avg << " s on average." << std::endl; | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
std::cerr << "ERROR: " << e.what() << std::endl; | ||
error = true; | ||
} | ||
#else | ||
const auto model = fdeep::load_model(model_path, true); | ||
#endif | ||
} | ||
|
||
if (error) | ||
{ | ||
std::cout << "There were errors." << std::endl; | ||
return 1; | ||
} | ||
std::cout << "All imports and test OK." << std::endl; | ||
}std::vector<std::string> model_paths = { | ||
// "convnextbase.json", | ||
// "convnextlarge.json", | ||
// "convnextsmall.json", | ||
// "convnexttiny.json", | ||
// "convnextxlarge.json", | ||
"densenet121.json", | ||
"densenet169.json", | ||
"densenet201.json", | ||
"efficientnetb0.json", | ||
"efficientnetb1.json", | ||
"efficientnetb2.json", | ||
"efficientnetb3.json", | ||
"efficientnetb4.json", | ||
"efficientnetb5.json", | ||
"efficientnetb6.json", | ||
"efficientnetb7.json", | ||
"efficientnetv2b0.json", | ||
"efficientnetv2b1.json", | ||
"efficientnetv2b2.json", | ||
"efficientnetv2b3.json", | ||
"efficientnetv2l.json", | ||
"efficientnetv2m.json", | ||
"efficientnetv2s.json", | ||
// "inceptionresnetv2.json", | ||
"inceptionv3.json", | ||
"mobilenet.json", | ||
"mobilenetv2.json", | ||
"nasnetlarge.json", | ||
"nasnetmobile.json", | ||
"resnet101.json", | ||
"resnet101v2.json", | ||
"resnet152.json", | ||
"resnet152v2.json", | ||
"resnet50.json", | ||
"resnet50v2.json", | ||
"vgg16.json", | ||
"vgg19.json", | ||
"xception.json" | ||
}; | ||
|
||
bool error = false; | ||
|
||
for (const auto& model_path : model_paths) | ||
{ | ||
std::cout << "----" << std::endl; | ||
std::cout << model_path << std::endl; | ||
#ifdef NDEBUG | ||
try | ||
{ | ||
const auto model = fdeep::load_model(model_path, true); | ||
const std::size_t warm_up_runs = 3; | ||
const std::size_t test_runs = 5; | ||
for (std::size_t i = 0; i < warm_up_runs; ++i) | ||
{ | ||
const double duration = model.test_speed(); | ||
std::cout << "Forward pass took " | ||
<< duration << " s." << std::endl; | ||
} | ||
double duration_sum = 0; | ||
std::cout << "Starting performance measurements." << std::endl; | ||
for (std::size_t i = 0; i < test_runs; ++i) | ||
{ | ||
const double duration = model.test_speed(); | ||
duration_sum += duration; | ||
std::cout << "Forward pass took " | ||
<< duration << " s." << std::endl; | ||
} | ||
const double duration_avg = | ||
duration_sum / static_cast<double>(test_runs); | ||
std::cout << "Forward pass took " | ||
<< duration_avg << " s on average." << std::endl; | ||
} | ||
catch (const std::exception& e) | ||
{ | ||
std::cerr << "ERROR: " << e.what() << std::endl; | ||
error = true; | ||
} | ||
#else | ||
const auto model = fdeep::load_model(model_path, true); | ||
#endif | ||
} | ||
|
||
if (error) | ||
{ | ||
std::cout << "There were errors." << std::endl; | ||
return 1; | ||
} | ||
std::cout << "All imports and test OK." << std::endl; | ||
} |