From: Sangjung Woo Date: Wed, 17 Feb 2021 00:51:10 +0000 (+0900) Subject: [MachineLearning.Inference][Non-ACR] Fix the potential bug (#2547) X-Git-Tag: accepted/tizen/unified/20210219.040944~11 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47638eadcaf1ab8e8c8d3b00094c6c15017f5ef7;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [MachineLearning.Inference][Non-ACR] Fix the potential bug (#2547) * [MachineLearning.Inference] Update the version number of the shared library This patch updates the version number of the nnstreamer library. * libcapi-nnstreamer.so.0 -> libcapi-nnstreamer.so.1 Signed-off-by: Sangjung Woo * [MachineLearning.Inference] Remove the name comparision in TensorsInfo.Equals() Since the name of the TensorsInfo is not used when negociating the pipeline, the name comparison in TensorsInfo.Equals() should be removed. Signed-off-by: Sangjung Woo * [MachineLearning.Inference] Add Clone() to TensorsInfo class for deep copy It is not a common case but developers can modify the TensorsInfo after creating the TensorsData. Because of this reason, TensorsData should have a hard-copied instance of the TensorsInfo object. If not, it shows the wrong information of TensorsData. This patch fixes this potential bug. Signed-off-by: Sangjung Woo --- diff --git a/src/Tizen.MachineLearning.Inference/Interop/Interop.Nnstreamer.cs b/src/Tizen.MachineLearning.Inference/Interop/Interop.Nnstreamer.cs index cba86ab..2dcd22f 100755 --- a/src/Tizen.MachineLearning.Inference/Interop/Interop.Nnstreamer.cs +++ b/src/Tizen.MachineLearning.Inference/Interop/Interop.Nnstreamer.cs @@ -22,7 +22,7 @@ internal static partial class Interop { internal static partial class Libraries { - public const string Nnstreamer = "libcapi-nnstreamer.so.0"; + public const string Nnstreamer = "libcapi-nnstreamer.so.1"; } internal static partial class Pipeline diff --git a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsData.cs b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsData.cs index ca6a6fc..330aacc 100755 --- a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsData.cs +++ b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsData.cs @@ -34,7 +34,7 @@ namespace Tizen.MachineLearning.Inference /// Creates a TensorsData instance with handle which is given by TensorsInfo. /// /// The handle of tensors data. - /// The handle of tensors info. (Default: null) + /// The handle of tensors info. /// The boolean value for fetching the data (Default: false) /// The boolean value for automatic disposal (Default: true) /// 6 @@ -45,7 +45,8 @@ namespace Tizen.MachineLearning.Inference /* Set internal object */ _handle = handle; - _tensorsInfo = info; + /* Because developers can change the TensorsInfo object, it should be stored as a deep-copied instance. */ + _tensorsInfo = info.Clone(); /* Set count */ int count = 0; @@ -202,6 +203,8 @@ namespace Tizen.MachineLearning.Inference if (disposing) { // release managed object + _tensorsInfo.Dispose(); + _tensorsInfo = null; } // release unmanaged objects diff --git a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs index d9f1d7c..2df0d49 100755 --- a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs +++ b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs @@ -327,10 +327,6 @@ namespace Tizen.MachineLearning.Inference for (int i = 0; i < this.Count; ++i) { - // Name - if (string.Compare(this.GetTensorName(i), other.GetTensorName(i)) != 0) - return false; - // Type if (this.GetTensorType(i) != other.GetTensorType(i)) return false; @@ -343,6 +339,23 @@ namespace Tizen.MachineLearning.Inference } /// + /// Create a new TensorsInfo object cloned from the current tensors information. + /// + /// Hard-copied TensorsInfo object + /// 9 + internal TensorsInfo Clone() + { + TensorsInfo retInfo = null; + retInfo = new TensorsInfo(); + + foreach (TensorInfo t in _infoList) { + retInfo.AddTensorInfo(t.Name, t.Type, t.Dimension); + } + + return retInfo; + } + + /// /// Make TensorsInfo object from Native handle /// /// Handle of TensorsInfo object