X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.MachineLearning.Inference%2FTizen.MachineLearning.Inference%2FTensorsInfo.cs;h=53c718f632b28ea85069c575dba6b76b58765c99;hb=ff12e68b44c23db10e1230e5e1917c4b639e5574;hp=4986b57ed9351d4094fd08f89f8a4f8e7e2da12e;hpb=c3a310fe53b2a474202bfd8da73b0725c1eda1d9;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git
diff --git a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
index 4986b57..53c718f 100755
--- a/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
+++ b/src/Tizen.MachineLearning.Inference/Tizen.MachineLearning.Inference/TensorsInfo.cs
@@ -39,9 +39,13 @@ namespace Tizen.MachineLearning.Inference
///
/// Creates a TensorsInfo instance.
///
+ /// http://tizen.org/feature/machine_learning.inference
+ /// Thrown when the feature is not supported.
/// 6
public TensorsInfo()
{
+ NNStreamer.CheckNNStreamerSupport();
+
Log.Info(NNStreamer.TAG, "TensorsInfo is created");
_infoList = new List();
}
@@ -67,6 +71,8 @@ namespace Tizen.MachineLearning.Inference
/// 6
public void AddTensorInfo(TensorType type, int[] dimension)
{
+ NNStreamer.CheckNNStreamerSupport();
+
AddTensorInfo(null, type, dimension);
}
@@ -83,6 +89,8 @@ namespace Tizen.MachineLearning.Inference
/// 6
public void AddTensorInfo(string name, TensorType type, int[] dimension)
{
+ NNStreamer.CheckNNStreamerSupport();
+
int idx = _infoList.Count;
if (idx >= Tensor.SizeLimit) {
throw new IndexOutOfRangeException("Max size of the tensors is " + Tensor.SizeLimit);
@@ -93,11 +101,9 @@ namespace Tizen.MachineLearning.Inference
{
NNStreamerError ret = NNStreamerError.None;
- /* Set the number of tensors */
ret = Interop.Util.SetTensorsCount(_handle, _infoList.Count);
NNStreamer.CheckException(ret, "unable to set the number of tensors");
- /* Set the type and dimension of Tensor */
ret = Interop.Util.SetTensorType(_handle, idx, type);
NNStreamer.CheckException(ret, "fail to set TensorsInfo type");
@@ -118,6 +124,8 @@ namespace Tizen.MachineLearning.Inference
/// 6
public void SetTensorName(int idx, string name)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
_infoList[idx].Name = name;
@@ -135,9 +143,12 @@ namespace Tizen.MachineLearning.Inference
/// The index of the tensor.
/// The tensor name.
/// Thrown when the index is greater than the number of Tensor.
+ /// Thrown when the feature is not supported.
/// 6
public string GetTensorName(int idx)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
return _infoList[idx].Name;
}
@@ -154,6 +165,8 @@ namespace Tizen.MachineLearning.Inference
/// 6
public void SetTensorType(int idx, TensorType type)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
_infoList[idx].Type = type;
@@ -172,9 +185,12 @@ namespace Tizen.MachineLearning.Inference
/// The tensor type
/// Thrown when the index is greater than the number of Tensor.
/// Thrown when the method failed due to an invalid parameter.
+ /// Thrown when the feature is not supported.
/// 6
public TensorType GetTensorType(int idx)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
return _infoList[idx].Type;
}
@@ -191,6 +207,8 @@ namespace Tizen.MachineLearning.Inference
/// 6
public void SetDimension(int idx, int[] dimension)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
_infoList[idx].SetDimension(dimension);
@@ -209,9 +227,12 @@ namespace Tizen.MachineLearning.Inference
/// The tensor dimension.
/// Thrown when the index is greater than the number of Tensor.
/// Thrown when the method failed due to an invalid parameter.
+ /// Thrown when the feature is not supported.
/// 6
public int[] GetDimension(int idx)
{
+ NNStreamer.CheckNNStreamerSupport();
+
CheckIndexBoundary(idx);
return _infoList[idx].Dimension;
}
@@ -226,10 +247,12 @@ namespace Tizen.MachineLearning.Inference
/// 6
public TensorsData GetTensorsData()
{
- IntPtr tensorsData_h;
+ IntPtr tensorsData_h = IntPtr.Zero;
TensorsData retTensorData;
NNStreamerError ret = NNStreamerError.None;
+ NNStreamer.CheckNNStreamerSupport();
+
if (_handle == IntPtr.Zero)
{
Log.Info(NNStreamer.TAG, "_handle is IntPtr.Zero\n" + " GetTensorsInfoHandle() is called");
@@ -238,7 +261,6 @@ namespace Tizen.MachineLearning.Inference
ret = Interop.Util.CreateTensorsData(_handle, out tensorsData_h);
NNStreamer.CheckException(ret, "unable to create the tensorsData object");
- Log.Info(NNStreamer.TAG, "success to CreateTensorsData()\n");
retTensorData = TensorsData.CreateFromNativeHandle(tensorsData_h);
@@ -248,7 +270,7 @@ namespace Tizen.MachineLearning.Inference
internal IntPtr GetTensorsInfoHandle()
{
NNStreamerError ret = NNStreamerError.None;
- IntPtr ret_handle;
+ IntPtr ret_handle = IntPtr.Zero;
int idx;
/* Already created */
@@ -314,8 +336,8 @@ namespace Tizen.MachineLearning.Inference
// release unmanaged objects
if (_handle != IntPtr.Zero)
{
- NNStreamerError ret = NNStreamerError.None;
- ret = Interop.Util.DestroyTensorsInfo(_handle);
+ NNStreamerError ret = Interop.Util.DestroyTensorsInfo(_handle);
+
if (ret != NNStreamerError.None)
{
Log.Error(NNStreamer.TAG, "failed to destroy TensorsInfo object");