From 4f9c32990c2df5c8d6ffda63f026f232efbeec91 Mon Sep 17 00:00:00 2001 From: hyunil park Date: Wed, 3 Aug 2022 17:27:31 +0900 Subject: [PATCH] [MachineLearning.Train] Remove CheckException in Dispose method of all class - Remove CheckException since GC can not catch exception, this is a rule Signed-off-by: hyunil park --- .../Tizen.MachineLearning.Train/Commons.cs | 2 +- .../Tizen.MachineLearning.Train/Dataset.cs | 4 ++-- src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs | 3 ++- src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs | 4 ++-- .../Tizen.MachineLearning.Train/Optimizer.cs | 3 ++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Commons.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Commons.cs index 471ef62..1780761 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Commons.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Commons.cs @@ -220,7 +220,7 @@ namespace Tizen.MachineLearning.Train /// /// Stochastic Gradient Descent Optimizer /// - Sgd = 1, + SGD = 1, /// /// Unknown Optimizer /// diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs index 51620c5..25747ad 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Dataset.cs @@ -82,8 +82,8 @@ namespace Tizen.MachineLearning.Train { // Destroy dataset. NNTrainerError ret = Interop.Dataset.Destroy(handle); - NNTrainer.CheckException(ret, "Failed to destroy dataset instance"); - Log.Info(NNTrainer.Tag, "Destroy Dataset"); + if (ret != NNTrainerError.None) + Log.Error(NNTrainer.Tag, "Failed to destroy Dataset instance"); handle = IntPtr.Zero; } diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs index 2135fa1..a34c17f 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Layer.cs @@ -103,7 +103,8 @@ namespace Tizen.MachineLearning.Train { // Destroy the neural network layer. NNTrainerError ret = Interop.Layer.Destroy(handle); - NNTrainer.CheckException(ret, "Failed to destroy layer instance"); + if (ret != NNTrainerError.None) + Log.Error(NNTrainer.Tag, "Failed to destroy Layer instance"); handle = IntPtr.Zero; } diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs index 1b053b0..cfb1106 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Model.cs @@ -100,8 +100,8 @@ namespace Tizen.MachineLearning.Train { // Destroy the neural network model. NNTrainerError ret = Interop.Model.Destroy(handle); - NNTrainer.CheckException(ret, "Failed to destroy model instance"); - + if (ret != NNTrainerError.None) + Log.Error(NNTrainer.Tag, "Failed to destroy Model instance"); handle = IntPtr.Zero; } disposed = true; diff --git a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs index a8ac08b..abc2a14 100644 --- a/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs +++ b/src/Tizen.MachineLearning.Train/Tizen.MachineLearning.Train/Optimizer.cs @@ -84,7 +84,8 @@ namespace Tizen.MachineLearning.Train { // Destroy optimizer. NNTrainerError ret = Interop.Optimizer.Destroy(handle); - NNTrainer.CheckException(ret, "Failed to destroy optimizer instance"); + if (ret != NNTrainerError.None) + Log.Error(NNTrainer.Tag, "Failed to destroy Optimizer instance"); handle = IntPtr.Zero; } -- 2.7.4