[MachineLearning.Train] Add Model constructor overloaing for model configuration...
authorHyunil <hyunil46.park@samsung.com>
Thu, 28 Apr 2022 02:18:38 +0000 (11:18 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 23 Aug 2022 05:50:26 +0000 (14:50 +0900)
- Add ml_train_model_construct_with_conf() to Interop

Signed-off-by: Hyunil <hyunil46.park@samsung.com>
src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs
src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs

index dea35c3..f50d4e6 100644 (file)
@@ -29,5 +29,9 @@ internal static partial class Interop
         /* typedef int ml_train_model_destroy(ml_train_model_h model) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_destroy")]
         public static extern NNTrainerError Destroy(IntPtr model_handle);
+
+        /* int ml_train_model_construct_with_conf(const char *model_conf, ml_train_model_h *model)*/
+        [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_construct_with_conf")]
+        public static extern NNTrainerError ConstructWithConf(string model_conf, out IntPtr model_handle);
     }
 }
index 66ecacc..c132fdd 100644 (file)
@@ -39,7 +39,7 @@ namespace Tizen.MachineLearning.Train
         private bool _disposed = false;
 
         /// <summary>
-        /// Create a new Model instance.
+        /// Constructs the neural network model.
         /// </summary>
         /// <since_tizen> 10 </since_tizen>
         public Model()
@@ -49,6 +49,19 @@ namespace Tizen.MachineLearning.Train
         }
 
         /// <summary>
+        /// Constructs the neural network model with the given configuration file.
+        /// </summary>
+        /// <param name="modelConf">The nntrainer model configuration file.</param>
+        /// <since_tizen> 10 </since_tizen>
+        public Model(string modelConf)
+        {
+            if (string.IsNullOrEmpty(modelConf))
+                NNTrainer.CheckException(NNTrainerError.InvalidParameter, "modelConf is null");
+
+            NNTrainerError ret = Interop.Model.ConstructWithConf(modelConf, out _handle);
+            NNTrainer.CheckException(ret, "Failed to create model instance with modelConf");
+        }
+        /// <summary>
         /// Destructor of Model
         /// </summary>
         /// <since_tizen> 10 </since_tizen>