From: Hyunil Date: Thu, 28 Apr 2022 02:18:38 +0000 (+0900) Subject: [MachineLearning.Train] Add Model constructor overloaing for model configuration... X-Git-Tag: accepted/tizen/unified/20231205.024657~783 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b0ac33c8c741d098b46c3cb06e7121c5212b53c0;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [MachineLearning.Train] Add Model constructor overloaing for model configuration file - Add ml_train_model_construct_with_conf() to Interop Signed-off-by: Hyunil --- diff --git a/src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs b/src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs index dea35c3..f50d4e6 100644 --- a/src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs +++ b/src/Tizen.MachineLearning.Train/Interop/Interop.Model.cs @@ -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); } } diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs index 66ecacc..c132fdd 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs @@ -39,7 +39,7 @@ namespace Tizen.MachineLearning.Train private bool _disposed = false; /// - /// Create a new Model instance. + /// Constructs the neural network model. /// /// 10 public Model() @@ -49,6 +49,19 @@ namespace Tizen.MachineLearning.Train } /// + /// Constructs the neural network model with the given configuration file. + /// + /// The nntrainer model configuration file. + /// 10 + 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"); + } + /// /// Destructor of Model /// /// 10