[MachineLearning.Train] Add GetSummaryUtil method to Model class
authorHyunil <hyunil46.park@samsung.com>
Thu, 26 May 2022 03:04:29 +0000 (12:04 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 23 Aug 2022 05:50:26 +0000 (14:50 +0900)
- Add GetSummary(NNTrainerSummaryType verbosity, out string retSummary) to Model
- Add ml_train_model_get_summary() to interop
- Add NNTrainerSummaryType to Commons.cs

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

index 63a30c8..3c24247 100644 (file)
@@ -41,5 +41,9 @@ internal static partial class Interop
         /* int ml_train_model_run(ml_train_model_h model, ...) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_run_with_single_param")]
         public static extern NNTrainerError Run(IntPtr model_handle, string run_params);
+
+        /* int ml_train_model_get_summary(ml_train_model_h model, ml_train_summary_type_e verbosity, char **summary) */
+        [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_model_get_summary")]
+        public static extern NNTrainerError GetSummaryUtil(IntPtr model_handle, NNTrainerSummaryType verbosity, out string summary);
     }
 }
index f7c7f58..6d89b52 100644 (file)
@@ -34,6 +34,27 @@ namespace Tizen.MachineLearning.Train
         InvalidOperation = ErrorCode.InvalidOperation
     }
 
+
+    /// <summary>
+    /// Enumeration for the neural network summary verbosity of NNTrainer.
+    /// </summary>
+    /// <since_tizen> 10 </since_tizen>
+    public enum NNTrainerSummaryType
+    {
+        /// <summary>
+        /// Overview of model summary with one-line layer information
+        /// </summary>
+        Model = 0,
+        /// <summary>
+        /// Detailed model summary with layer properties
+        /// </summary>
+        Layer = 1,
+        /// <summary>
+        /// Model summary layer's including weight information
+        /// </summary>
+        Tensor = 2
+    }
+
     internal static class NNTrainer
     {
  
index f7e596c..f74cdd8 100644 (file)
@@ -93,7 +93,6 @@ namespace Tizen.MachineLearning.Train
             {
                 // release managed object
             }
-
             // release unmanaged object
             if (_handle != IntPtr.Zero)
             {
@@ -154,5 +153,22 @@ namespace Tizen.MachineLearning.Train
             NNTrainer.CheckException(ret, "Failed to run model");
         }
 
+        /// <summary>
+        /// Gets the summary of the neural network model.
+        /// </summary>
+        /// <remarks>
+        /// Use this function to get the summary of the neural network model.
+        /// </remarks>
+        /// <param name="verbosity">Verbose level of the summary.</param>
+        /// <param name="retSummary">On return, a string value. The summary of the current model. Avoid logic to parse and exploit summary if possible.</param>
+        /// <since_tizen> 10 </since_tizen>
+        public void GetSummaryUtil(NNTrainerSummaryType verbosity, out string retSummary)
+        {
+            NNTrainerError ret = Interop.Model.GetSummaryUtil(_handle, verbosity, out string summary);
+            NNTrainer.CheckException(ret, "Failed to get summary");
+
+            retSummary = summary;
+
+        }
     } 
 }