[MachineLearning.Train] Add SetProperty method to Dataset class
authorHyunil <hyunil46.park@samsung.com>
Thu, 23 Jun 2022 02:34:19 +0000 (11:34 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Tue, 23 Aug 2022 05:50:26 +0000 (14:50 +0900)
-Add SetProperty(NNTrainerDatasetMode mode, params string[] property)
-Add ml_train_dataset_set_property_for_mode_with_single_param() to interop

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

index 53f6e4d..1c02758 100644 (file)
@@ -33,5 +33,9 @@ internal static partial class Interop
         /* int ml_train_dataset_add_file(ml_train_dataset_h dataset, ml_train_dataset_mode_e mode, const char *file) */
         [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_dataset_add_file")]
         internal static extern NNTrainerError AddFile(IntPtr datasetHandle, NNTrainerDatasetMode mode, string file);
+
+        /* int ml_train_dataset_set_property_for_mode_with_single_param(ml_train_dataset_h dataset, ml_train_dataset_mode_e mode, const char *single_param) */
+        [DllImport(Libraries.Nntrainer, EntryPoint = "ml_train_dataset_set_property_for_mode_with_single_param")]
+        internal static extern NNTrainerError SetProperty(IntPtr datasetHandle, NNTrainerDatasetMode mode, string propertyParams);
     }
 }
index fe881f1..916dc6d 100644 (file)
@@ -118,5 +118,27 @@ namespace Tizen.MachineLearning.Train
         {
             return handle;
         }
+
+        /// <summary>
+        /// Sets the neural network dataset property.
+        /// </summary>
+        /// <remarks>
+        /// Use this function to set dataset property for a specific mode.
+        /// </remarks>
+        /// <param name="mode">The mode to set the property.</param>
+        /// <param name="property">property for dataset.</param>
+        /// <since_tizen> 10 </since_tizen>
+        public void SetProperty(NNTrainerDatasetMode mode, params string[] property)
+        {
+            string propertyParams = null;
+
+            if (property.Length > 0) {
+                propertyParams = string.Join("|", property);
+                Log.Info(NNTrainer.Tag, "Set property:"+ propertyParams);
+            }
+
+            NNTrainerError ret = Interop.Dataset.SetProperty(handle, mode, propertyParams);
+            NNTrainer.CheckException(ret, "Failed to set property");
+        }
     } 
 }