Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ unittest/modelfile ] Fix backbone_20 @open sesame 10/25 10:21 #2771

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions test/unittest/unittest_nntrainer_modelfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ static nntrainer::IniSection conv2d_shape("conv2d_shape",
"stride = 1,1 |"
"padding = 0,0 |");

static nntrainer::IniSection input2d("inputlayer", "Type = input |"
"Input_Shape = 3:100:100");
static nntrainer::IniSection input2d("inputlayer2d", "Type = input |"
"Input_Shape = 3:100:100");

static nntrainer::IniSection backbone_random("block1", "backbone = random.ini");

Expand Down Expand Up @@ -508,7 +508,8 @@ TEST(nntrainerIniTest, backbone_04_p) {
// ScopedIni backbone_made(
// "backbone_made", {nw_base_cross, sgd, input2d,
// I("block1") + backbone_valid +
// "input_layers=inputlayer", I("block2") + backbone_valid
// "input_layers=inputlayer2d", I("block2") +
// backbone_valid
// + "input_layers=block1", I("block3") + backbone_valid +
// "input_layers=block2", I("block4") + backbone_valid +
// "input_layers=block3"});
Expand All @@ -529,7 +530,7 @@ TEST(nntrainerIniTest, backbone_04_p) {
// // std::string conv2d_orig_name = conv2d.getName();
// ScopedIni direct_made(
// "direct_made", {nw_base_cross, sgd, input2d,
// I("block1conv2d") + conv2d + "input_layers=inputlayer",
// I("block1conv2d") + conv2d + "input_layers=inputlayer2d",
// I("block2conv2d") + conv2d + "input_layers=block1conv2d",
// I("block3conv2d") + conv2d + "input_layers=block2conv2d",
// I("block4conv2d") + conv2d +
Expand Down Expand Up @@ -667,15 +668,15 @@ TEST(nntrainerIniTest, backbone_17_p) {

ScopedIni full(
"backbone_17_p_full",
{nw_base_mse, adam, input2d, backbone_valid + "input_layers=inputlayer"});
{nw_base_mse, adam, input2d, backbone_valid + "input_layers=inputlayer2d"});

EXPECT_EQ(NN_full.loadFromConfig(full.getIniName()), ML_ERROR_NONE);
EXPECT_EQ(NN_full.compile(), ML_ERROR_NONE);
EXPECT_EQ(NN_full.initialize(), ML_ERROR_NONE);

ScopedIni scaled(
"backbone_17_p_scaled",
{nw_base_mse, adam, input2d, backbone_scaled + "input_layers=inputlayer"});
ScopedIni scaled("backbone_17_p_scaled",
{nw_base_mse, adam, input2d,
backbone_scaled + "input_layers=inputlayer2d"});

EXPECT_EQ(NN_scaled.loadFromConfig(scaled.getIniName()), ML_ERROR_NONE);
EXPECT_EQ(NN_scaled.compile(), ML_ERROR_NONE);
Expand All @@ -690,7 +691,7 @@ TEST(nntrainerIniTest, backbone_17_p) {
// TEST(nntrainerIniTest, backbone_18_n) {
// nntrainer::NeuralNetwork NN;

// ScopedIni base("base", {input2d, conv2d + "input_layers=inputlayer",
// ScopedIni base("base", {input2d, conv2d + "input_layers=inputlayer2d",
// flatten + "input_layers=conv2d"});
// ScopedIni backbone("Backbone_18_n",
// {nw_base_mse, adam, input,
Expand All @@ -705,43 +706,42 @@ TEST(nntrainerIniTest, backbone_17_p) {
* @note Input layer name not found, empty backbone
* @todo fix this testcase to check unknown input layer name
*/
// TEST(nntrainerIniTest, backbone_19_n) {
// nntrainer::NeuralNetwork NN;
TEST(nntrainerIniTest, backbone_19_n) {
nntrainer::NeuralNetwork NN;

// ScopedIni base("base", {input2d, conv2d + "input_layers=inputlayer",
// batch_normal + "input_layers=conv2d"});
ScopedIni base("base", {input2d, conv2d + "input_layers=inputlayer2d",
batch_normal + "input_layers=conv2d"});

// ScopedIni backbone("backbone_19_n",
// {nw_base_mse, adam, input,
// backbone_valid_inout + "input_layers=inputlayer"});
ScopedIni backbone("backbone_19_n",
{nw_base_mse, adam, input,
backbone_valid_inout + "input_layers=inputlayer"});

// EXPECT_EQ(NN.loadFromConfig(backbone.getIniName()),
// ML_ERROR_INVALID_PARAMETER);
// }
EXPECT_EQ(NN.loadFromConfig(backbone.getIniName()),
ML_ERROR_INVALID_PARAMETER);
}

/**
* @brief Ini file unittest with backbone
* @note input and output layer specified are found
* @todo C++ exception with description "Failed to initialize: in size + padding
* is smaller than effective kernel" thrown in the test body.
*/
// TEST(nntrainerIniTest, backbone_20_p) {
// nntrainer::NeuralNetwork NN;
TEST(nntrainerIniTest, backbone_20_p) {
nntrainer::NeuralNetwork NN;

// ScopedIni base("base",
// {input2d, conv2d + "input_layers=inputlayer",
// flatten + "input_layers=conv2d", out +
// "input_layers=flat"});
ScopedIni base("base",
{input2d, conv2d + "input_layers=inputlayer2d",
flatten + "input_layers=conv2d", out + "input_layers=flat"});

// ScopedIni backbone("backbone_20_p",
// {nw_base_mse, adam, input,
// backbone_valid_inout + "input_layers=inputlayer"});
ScopedIni backbone("backbone_20_p",
{nw_base_mse, adam, input,
backbone_valid_inout + "input_layers=inputlayer"});

// EXPECT_EQ(NN.loadFromConfig(backbone.getIniName()), ML_ERROR_NONE);
// EXPECT_EQ(NN.compile(), ML_ERROR_NONE);
// EXPECT_EQ(NN.initialize(), ML_ERROR_NONE);
// EXPECT_EQ(NN.size(), 6u);
// }
EXPECT_EQ(NN.loadFromConfig(backbone.getIniName()), ML_ERROR_NONE);
EXPECT_EQ(NN.compile(), ML_ERROR_NONE);
EXPECT_EQ(NN.initialize(), ML_ERROR_NONE);
EXPECT_EQ(NN.size(), 10u);
}

/**
* @brief backbone is relative to original ini, if working directory is not set,
Expand Down
Loading