-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR includes the mixed precision test case. . Input - FC - MSE : "batch_size=2", "model_tensor_type=FP16-FP16", "loss_scale=128" **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: jijoong.moon <[email protected]>
- Loading branch information
1 parent
8b7b44f
commit b51af11
Showing
3 changed files
with
59 additions
and
1 deletion.
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
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,54 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/** | ||
* Copyright (C) 2024 Jijoong Moon <[email protected]> | ||
* | ||
* @file unittest_models_mixed_precision.cpp | ||
* @date 3 May 2024 | ||
* @brief unittest models to cover mixed precision | ||
* @see https://github.com/nnstreamer/nntrainer | ||
* @author Jijoong Moon <[email protected]> | ||
* @bug No known bugs except for NYI items | ||
*/ | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <memory> | ||
|
||
#include <ini_wrapper.h> | ||
#include <neuralnet.h> | ||
#include <nntrainer_test_util.h> | ||
|
||
#include <models_golden_test.h> | ||
|
||
using namespace nntrainer; | ||
|
||
static std::unique_ptr<NeuralNetwork> fc_mixed_training() { | ||
std::unique_ptr<NeuralNetwork> nn(new NeuralNetwork()); | ||
nn->setProperty( | ||
{"batch_size=2", "model_tensor_type=FP16-FP16", "loss_scale=128"}); | ||
|
||
auto graph = makeGraph({ | ||
{"input", {"name=in", "input_shape=1:1:3"}}, | ||
{"Fully_connected", {"name=fc", "input_layers=in", "unit=10"}}, | ||
{"mse", {"name=loss", "input_layers=fc"}}, | ||
}); | ||
for (auto &node : graph) { | ||
nn->addLayer(node); | ||
} | ||
|
||
nn->setOptimizer(ml::train::createOptimizer("adam", {"learning_rate = 0.1"})); | ||
|
||
return nn; | ||
} | ||
|
||
GTEST_PARAMETER_TEST( | ||
MixedPrecision, nntrainerModelTest, | ||
::testing::ValuesIn({ | ||
mkModelTc_V2(fc_mixed_training, "fc_mixed_training", | ||
ModelTestOption::NO_THROW_RUN_V2), | ||
/** ModelTestOption::ALL_V2), | ||
* Disabled for now to check | ||
*/ | ||
}), | ||
[](const testing::TestParamInfo<nntrainerModelTest::ParamType> &info) | ||
-> const auto & { return std::get<1>(info.param); }); |