[Fix] Svace issue and minor bugs accepted/tizen/unified/20210916.123506 submit/tizen/20210916.080313
authorJihoon Lee <jhoon.it.lee@samsung.com>
Wed, 15 Sep 2021 11:52:01 +0000 (20:52 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 16 Sep 2021 01:37:53 +0000 (10:37 +0900)
**Changes proposed in this PR:**
- implement save_ini_with_bin format
- delete noexcept specifier in node exporter
- ini interpreter skips newly reserved sections
- Add member initializer in TfOpNode
- fix unused warning in padding for under gcc 9

**Self evaluation:**
1. Build test: [X]Passed [ ]Failed [ ]Skipped
2. Run test: [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: Jihoon Lee <jhoon.it.lee@samsung.com>
nntrainer/compiler/ini_interpreter.cpp
nntrainer/compiler/tflite_opnode.cpp
nntrainer/layers/pooling2d_layer.cpp
nntrainer/models/model_loader.cpp
nntrainer/models/neuralnet.cpp
nntrainer/utils/node_exporter.cpp
nntrainer/utils/node_exporter.h

index 45e19f2..140104a 100644 (file)
@@ -38,6 +38,9 @@ static constexpr const char *UNKNOWN_STR = "UNKNOWN";
 static constexpr const char *NONE_STR = "NONE";
 static constexpr const char *MODEL_STR = "model";
 static constexpr const char *DATASET_STR = "dataset";
+static constexpr const char *TRAINSET_STR = "train_set";
+static constexpr const char *VALIDSET_STR = "valid_set";
+static constexpr const char *TESTSET_STR = "test_set";
 static constexpr const char *OPTIMIZER_STR = "optimizer";
 
 namespace nntrainer {
@@ -302,6 +305,9 @@ IniGraphInterpreter::deserialize(const std::string &in) {
       std::string sec_name(sec_name_);
 
       if (istrequal(sec_name, MODEL_STR) || istrequal(sec_name, DATASET_STR) ||
+          istrequal(sec_name, TRAINSET_STR) ||
+          istrequal(sec_name, VALIDSET_STR) ||
+          istrequal(sec_name, TESTSET_STR) ||
           istrequal(sec_name, OPTIMIZER_STR)) {
         /// dedicated sections so skip
         continue;
index 48331f8..dfad200 100644 (file)
 
 namespace nntrainer {
 
-TfOpNode::TfOpNode(){};
+TfOpNode::TfOpNode() :
+  inputs(),
+  outputs(),
+  weights(),
+  weight_transform(nullptr),
+  is_input(false),
+  is_output(false),
+  node_owned_variable(),
+  op_type(tflite::BuiltinOperator_ADD),
+  builtin_ops(),
+  builtin_option_type(tflite::BuiltinOptions_NONE){};
 
 void TfOpNode::setLayerNode(const LayerNode &layer) {
   is_input = layer.getNumInputConnections() == 0;
index 08b3a62..e2e03b0 100644 (file)
@@ -159,7 +159,8 @@ void Pooling2DLayer::calcDerivative(RunLayerContext &context) {
   int height = in_dim.height();
   int width = in_dim.width();
 
-  auto [pt, pb, pl, pr] = padding;
+  auto pt = padding[0];
+  auto pl = padding[2];
   unsigned int p_height = pool_size[0];
   unsigned int p_width = pool_size[1];
 
index 0622499..c2524fe 100644 (file)
@@ -275,7 +275,7 @@ int ModelLoader::loadDatasetConfigIni(dictionary *ini, NeuralNetwork &model) {
   NN_RETURN_STATUS();
   status = parse_buffer_section("valid_set", DatasetModeType::MODE_VALID);
   NN_RETURN_STATUS();
-  status = parse_buffer_section("test", DatasetModeType::MODE_TEST);
+  status = parse_buffer_section("test_set", DatasetModeType::MODE_TEST);
   NN_RETURN_STATUS();
 
   return status;
index b971aa8..820d6a2 100644 (file)
@@ -333,6 +333,18 @@ void NeuralNetwork::save(const std::string &file_path,
   case ml::train::ModelFormat::MODEL_FORMAT_INI:
     saveModelIni(file_path);
     break;
+
+  case ml::train::ModelFormat::MODEL_FORMAT_INI_WITH_BIN: {
+    auto old_save_path = std::get<props::SavePath>(model_flex_props);
+    auto bin_file_name =
+      file_path.substr(0, file_path.find_last_of('.')) + ".bin";
+
+    std::get<props::SavePath>(model_flex_props).set(bin_file_name);
+    save(file_path, ml::train::ModelFormat::MODEL_FORMAT_INI);
+    save(bin_file_name, ml::train::ModelFormat::MODEL_FORMAT_BIN);
+    std::get<props::SavePath>(model_flex_props) = old_save_path;
+    break;
+  }
   default:
     throw nntrainer::exception::not_supported(
       "saving with given format is not supported yet");
index fc5c75c..66e2fe6 100644 (file)
@@ -35,14 +35,13 @@ Exporter::~Exporter() = default;
 
 template <>
 std::unique_ptr<std::vector<std::pair<std::string, std::string>>>
-Exporter::getResult<ExportMethods::METHOD_STRINGVECTOR>() noexcept {
+Exporter::getResult<ExportMethods::METHOD_STRINGVECTOR>() {
   return std::move(stored_result);
 }
 
 #ifdef ENABLE_TFLITE_INTERPRETER
 template <>
-std::unique_ptr<TfOpNode>
-Exporter::getResult<ExportMethods::METHOD_TFLITE>() noexcept {
+std::unique_ptr<TfOpNode> Exporter::getResult<ExportMethods::METHOD_TFLITE>() {
   tf_node->finalize();
   return std::move(tf_node);
 }
index e2fded9..6e171c0 100644 (file)
@@ -160,7 +160,7 @@ public:
    */
   template <ExportMethods methods,
             typename T = typename return_type<methods>::type>
-  std::unique_ptr<T> getResult() noexcept;
+  std::unique_ptr<T> getResult();
 
 private:
   /**