From 47e30b2ad64d8407077d34959e7608733fc0d9fd Mon Sep 17 00:00:00 2001 From: Sangjung Woo Date: Fri, 8 Nov 2019 17:00:58 +0900 Subject: [PATCH] [MachineLearning.Inference][Non-ACR] Handle NotSupportedException logic Change-Id: I410682889c171b0f26b649c207eefd37286542c7 Signed-off-by: Sangjung Woo --- .../testcase/TSSingleShot.cs | 137 +++-- .../testcase/TSTensorsData.cs | 144 +++-- .../testcase/TSTensorsInfo.cs | 671 ++++++++++++++------- 3 files changed, 670 insertions(+), 282 deletions(-) diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs index b732b1b..724a7a5 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSSingleShot.cs @@ -19,6 +19,7 @@ using NUnit.Framework.TUnit; using System; using System.IO; using Tizen; +using Tizen.System; using Tizen.MachineLearning.Inference; namespace Tizen.MachineLearning.Inference.Tests { @@ -33,16 +34,24 @@ namespace Tizen.MachineLearning.Inference.Tests { private TensorsInfo _in_info; private TensorsInfo _out_info; + private const string FeatureKey = "http://tizen.org/feature/machine_learning.inference"; + private bool _isMachineLeanringInferenceSupported = false; + [SetUp] public void Init() { LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.MachineLearning.Inference TEST"); - _in_info = new TensorsInfo(); - _in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 3, 224, 224, 1 }); + Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported); + + if (_isMachineLeanringInferenceSupported) + { + _in_info = new TensorsInfo(); + _in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 3, 224, 224, 1 }); - _out_info = new TensorsInfo(); - _out_info.AddTensorInfo(TensorType.UInt8, new int[4] { 1001, 1, 1, 1 }); + _out_info = new TensorsInfo(); + _out_info.AddTensorInfo(TensorType.UInt8, new int[4] { 1001, 1, 1, 1 }); + } } [TearDown] @@ -50,8 +59,11 @@ namespace Tizen.MachineLearning.Inference.Tests { { LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.MachineLearning.Inference TEST"); - _in_info.Dispose(); - _out_info.Dispose(); + if (_isMachineLeanringInferenceSupported) + { + _in_info.Dispose(); + _out_info.Dispose(); + } } [Test] @@ -63,11 +75,11 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")] public void SingleShot_INIT() { - /* TEST CODE */ Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file"); try { + /* TEST CODE */ var single = new SingleShot(_modelPath, _in_info, _out_info); Assert.IsInstanceOf(single, "Should return SingleShot instance"); Assert.IsNotNull(single, "Failed to create SingleShot instance"); @@ -76,7 +88,15 @@ namespace Tizen.MachineLearning.Inference.Tests { } catch (Exception e) { - Assert.True(false, e.Message); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -91,11 +111,24 @@ namespace Tizen.MachineLearning.Inference.Tests { { try { + /* TEST CODE */ var single = new SingleShot("Unknown_Path", _in_info, _out_info); } - catch (ArgumentException) + catch (Exception e) { - Assert.Pass("ArgumentException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail("Unexpected Exception: failed"); + } } } @@ -118,19 +151,19 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(out_buffer_origin, "out_buffer_origin payload is not of the of the type byte[]"); Assert.IsNotNull(out_buffer_origin, "Fail to create the out_buffer_origin the type byte[] "); - var single = new SingleShot(_modelPath, _in_info, _out_info); - Assert.IsInstanceOf(single, "Should return SingleShot instance"); - Assert.IsNotNull(single, "Failed to create SingleShot instance"); + try + { + var single = new SingleShot(_modelPath, _in_info, _out_info); + Assert.IsInstanceOf(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); - var in_data = _in_info.GetTensorsData(); - Assert.IsInstanceOf(in_data, "Should return TensorsData instance"); - Assert.IsNotNull(in_data, "Failed to create TensorsData instance"); + var in_data = _in_info.GetTensorsData(); + Assert.IsInstanceOf(in_data, "Should return TensorsData instance"); + Assert.IsNotNull(in_data, "Failed to create TensorsData instance"); - in_data.SetTensorData(0, in_buffer); + in_data.SetTensorData(0, in_buffer); - /* TEST CODE */ - try - { + /* TEST CODE */ var out_data = single.Invoke(in_data); Assert.IsInstanceOf(out_data, "Should return TensorsData instance"); Assert.IsNotNull(out_data, "Failed to create TensorsData instance"); @@ -138,13 +171,21 @@ namespace Tizen.MachineLearning.Inference.Tests { var out_buffer = out_data.GetTensorData(0); Assert.IsInstanceOf(out_buffer, "Should return byte[] instance"); Assert.IsNotNull(out_buffer, "Failed to create byte[] instance"); + + single.Dispose(); } catch (Exception e) { - Assert.True(false, e.Message); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } - - single.Dispose(); } [Test] @@ -158,34 +199,46 @@ namespace Tizen.MachineLearning.Inference.Tests { { Assert.IsTrue(File.Exists(_modelPath), "Cannot find the mobilenet_v1_1.0_224_quant.tflite file"); - var in_info = new TensorsInfo(); - Assert.IsInstanceOf(in_info, "Should return TensorsInfo instance"); - Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance"); + try + { + var in_info = new TensorsInfo(); + Assert.IsInstanceOf(in_info, "Should return TensorsInfo instance"); + Assert.IsNotNull(in_info, "Failed to create TensorsInfo instance"); - var in_buffer = new byte[10 * 1 * 1 * 1]; - Assert.IsInstanceOf(in_buffer, "in_buffer payload is not of the of the type byte[]"); - Assert.IsNotNull(in_buffer, "Fail to create the in_buffer the type byte[] "); + var in_buffer = new byte[10 * 1 * 1 * 1]; + Assert.IsInstanceOf(in_buffer, "in_buffer payload is not of the of the type byte[]"); + Assert.IsNotNull(in_buffer, "Fail to create the in_buffer the type byte[] "); - in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 10, 1, 1, 1 }); + in_info.AddTensorInfo(TensorType.UInt8, new int[4] { 10, 1, 1, 1 }); - var in_data = _in_info.GetTensorsData(); - Assert.IsInstanceOf(in_data, "Should return TensorsData instance"); - Assert.IsNotNull(in_data, "Fail to create the TensorsData instance"); + var in_data = _in_info.GetTensorsData(); + Assert.IsInstanceOf(in_data, "Should return TensorsData instance"); + Assert.IsNotNull(in_data, "Fail to create the TensorsData instance"); - in_data.SetTensorData(0, in_buffer); + in_data.SetTensorData(0, in_buffer); - var single = new SingleShot(_modelPath, _in_info, _out_info); - Assert.IsInstanceOf(single, "Should return SingleShot instance"); - Assert.IsNotNull(single, "Failed to create SingleShot instance"); + var single = new SingleShot(_modelPath, _in_info, _out_info); + Assert.IsInstanceOf(single, "Should return SingleShot instance"); + Assert.IsNotNull(single, "Failed to create SingleShot instance"); - /* TEST CODE */ - try - { + /* TEST CODE */ var out_data = single.Invoke(in_data); } - catch (IOException) + catch (Exception e) { - Assert.Pass("IOException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IOException) + { + Assert.Pass("IOException: passed!"); + } + else + { + Assert.Fail("Unexpected Exception: failed"); + } } } } diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs index 36edbaf..eb2f6c0 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsData.cs @@ -18,6 +18,7 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; using Tizen; +using Tizen.System; using Tizen.MachineLearning.Inference; namespace Tizen.MachineLearning.Inference.Tests { @@ -26,18 +27,27 @@ namespace Tizen.MachineLearning.Inference.Tests { public class TensorsDataTests { private readonly string TAG = "Tizen.MachineLearning.Inference TCT"; - private TensorsInfo _tensorsInfo; + private TensorsInfo _tensorsInfo = null; private int[] _in_dim; + private const string FeatureKey = "http://tizen.org/feature/machine_learning.inference"; + private bool _isMachineLeanringInferenceSupported = false; + [SetUp] public void Init() { LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Preconditions for Tizen.MachineLearning.Inference TEST"); - _tensorsInfo = new TensorsInfo(); - _in_dim = new int[4] { 10, 1, 1, 1 }; + Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported); + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "#### MachineLeanringInferenceSupported: " + _isMachineLeanringInferenceSupported.ToString()); + + if (_isMachineLeanringInferenceSupported) + { + _tensorsInfo = new TensorsInfo(); + _in_dim = new int[4] { 10, 1, 1, 1 }; - _tensorsInfo.AddTensorInfo(TensorType.UInt8, _in_dim); + _tensorsInfo.AddTensorInfo(TensorType.UInt8, _in_dim); + } } [TearDown] @@ -45,7 +55,8 @@ namespace Tizen.MachineLearning.Inference.Tests { { LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "Postconditions for Tizen.MachineLearning.Inference TEST"); - _tensorsInfo.Dispose(); + if (_isMachineLeanringInferenceSupported) + _tensorsInfo.Dispose(); } [Test] @@ -73,7 +84,15 @@ namespace Tizen.MachineLearning.Inference.Tests { } catch (Exception e) { - Assert.True(false, e.Message); + if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null)) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -92,15 +111,28 @@ namespace Tizen.MachineLearning.Inference.Tests { try { + /* TEST CODE */ var tensorsData = _tensorsInfo.GetTensorsData(); Assert.IsInstanceOf(tensorsData, "tensorsData payload is not of the of the TensorsData."); Assert.IsNotNull(tensorsData, "Fail to create the tensorsData."); tensorsData.SetTensorData(10, buffer_in); } - catch (ArgumentException) + catch (Exception e) { - Assert.Pass("ArgumentException: passed!"); + if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null)) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail("Unexpected Exception: failed"); + } } } @@ -117,25 +149,40 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(buffer_in, "buffer_in is not the type of byte[]."); Assert.IsNotNull(buffer_in, "Fail to create buffer_in."); - var tensorsData = _tensorsInfo.GetTensorsData(); - Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); - Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); + try + { + var tensorsData = _tensorsInfo.GetTensorsData(); + Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); + Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); + + tensorsData.SetTensorData(0, buffer_in); - tensorsData.SetTensorData(0, buffer_in); + /* TEST CODE */ + var buffer_out = tensorsData.GetTensorData(0); + Assert.IsInstanceOf(buffer_out, "buffer_out is not the type of byte[]."); + Assert.IsNotNull(buffer_out, "Fail to create buffer_out."); - /* TEST CODE */ - var buffer_out = tensorsData.GetTensorData(0); - Assert.IsInstanceOf(buffer_out, "buffer_out is not the type of byte[]."); - Assert.IsNotNull(buffer_out, "Fail to create buffer_out."); + Assert.IsTrue(buffer_in.Length == buffer_out.Length, "The length of buffer_out payload is different from buffer_in."); - Assert.IsTrue(buffer_in.Length == buffer_out.Length, "The length of buffer_out payload is different from buffer_in."); + for (int i = 0; i < buffer_out.Length; ++i) + { + Assert.IsTrue(buffer_in[i] == buffer_out[i], "The value of buffer_in is different from that of buffer_out"); + } - for (int i = 0; i < buffer_out.Length; ++i) + tensorsData.Dispose(); + } + catch (Exception e) { - Assert.IsTrue(buffer_in[i] == buffer_out[i], "The value of buffer_in is different from that of buffer_out"); + if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null)) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } - - tensorsData.Dispose(); } [Test] @@ -151,20 +198,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(buffer_in, "buffer_in is not the type of byte[]."); Assert.IsNotNull(buffer_in, "Fail to create buffer_in."); - var tensorsData = _tensorsInfo.GetTensorsData(); - Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); - Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); - - tensorsData.SetTensorData(0, buffer_in); - try { + var tensorsData = _tensorsInfo.GetTensorsData(); + Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); + Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); + + tensorsData.SetTensorData(0, buffer_in); + /* TEST CODE */ var buffer_out = tensorsData.GetTensorData(100); } - catch (ArgumentException) + catch (Exception e) { - Assert.Pass("ArgumentException: passed!"); + if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null)) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.Fail("Unexpected Exception: failed"); + } } } @@ -181,14 +240,29 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(buffer_in, "buffer_in is not the type of byte[]."); Assert.IsNotNull(buffer_in, "Fail to create buffer_in."); - var tensorsData = _tensorsInfo.GetTensorsData(); - Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); - Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); + try + { + var tensorsData = _tensorsInfo.GetTensorsData(); + Assert.IsInstanceOf(tensorsData, "tensorsData is not the type of TensorsData."); + Assert.IsNotNull(tensorsData, "Fail to create tensorsData."); - tensorsData.SetTensorData(0, buffer_in); + tensorsData.SetTensorData(0, buffer_in); - /* TEST CODE */ - Assert.IsTrue(1 == tensorsData.Count, "The number of Tensor in TensorsData is different from the origin."); + /* TEST CODE */ + Assert.IsTrue(1 == tensorsData.Count, "The number of Tensor in TensorsData is different from the origin."); + } + catch (Exception e) + { + if ((e is NotSupportedException) || (e is NullReferenceException && _tensorsInfo == null)) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } } } diff --git a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs index 3977307..20ba274 100755 --- a/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs +++ b/tct-suite-vs/Tizen.MachineLearning.Inference.Tests/testcase/TSTensorsInfo.cs @@ -18,6 +18,7 @@ using NUnit.Framework; using NUnit.Framework.TUnit; using System; using Tizen; +using Tizen.System; using Tizen.MachineLearning.Inference; namespace Tizen.MachineLearning.Inference.Tests { @@ -28,10 +29,15 @@ namespace Tizen.MachineLearning.Inference.Tests { { private readonly string TAG = "Tizen.MachineLearning.Inference TCT"; + private const string FeatureKey = "http://tizen.org/feature/machine_learning.inference"; + private bool _isMachineLeanringInferenceSupported = false; + [SetUp] public void Init() { LogUtils.Write(LogUtils.DEBUG , LogUtils.TAG , "Preconditions for Tizen.MachineLearning.Inference TEST"); + + Information.TryGetValue(FeatureKey, out _isMachineLeanringInferenceSupported); } [TearDown] @@ -60,10 +66,19 @@ namespace Tizen.MachineLearning.Inference.Tests { } catch (Exception e) { - Assert.True(false, e.Message); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } + [Test] [Category("P1")] [Description("Add TensorInfo into TensorsInfo with the input dimension information")] @@ -78,29 +93,37 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + /* TEST CODE */ tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - } - catch (Exception e) - { - Assert.True(false, e.Message); - } - Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.UInt8, "The TensorType is not TensorType.UInt8."); + Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.UInt8, "The TensorType is not TensorType.UInt8."); - var in_res = tensorsInfo.GetDimension(0); - Assert.IsInstanceOf(in_res, "Should return int[] instance"); - Assert.IsNotNull(in_res, "Failed to create in_res instance"); + var in_res = tensorsInfo.GetDimension(0); + Assert.IsInstanceOf(in_res, "Should return int[] instance"); + Assert.IsNotNull(in_res, "Failed to create in_res instance"); - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) + { + Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + } + } + catch (Exception e) { - Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -117,38 +140,45 @@ namespace Tizen.MachineLearning.Inference.Tests { var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - string TensorName = "InputTensorName"; try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + /* TEST CODE */ tensorsInfo.AddTensorInfo(TensorName, TensorType.UInt8, in_dim); - } - catch (Exception e) - { - Assert.True(false, e.Message); - } - /* Type checking */ - Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.UInt8, "The TensorType is not TensorType.UInt8."); + /* Type checking */ + Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.UInt8, "The TensorType is not TensorType.UInt8."); - /* Dimension checking */ - var in_res = tensorsInfo.GetDimension(0); - Assert.IsInstanceOf(in_res, "Should return int[] instance"); - Assert.IsNotNull(in_res, "Failed to create in_res instance"); + /* Dimension checking */ + var in_res = tensorsInfo.GetDimension(0); + Assert.IsInstanceOf(in_res, "Should return int[] instance"); + Assert.IsNotNull(in_res, "Failed to create in_res instance"); - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) + { + Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + } + + /* Name checking */ + Assert.IsTrue(tensorsInfo.GetTensorName(0) == TensorName, "The name of Input Tensor is different from the origin."); + } + catch (Exception e) { - Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } - - /* Name checking */ - Assert.IsTrue(tensorsInfo.GetTensorName(0) == TensorName, "The name of Input Tensor is different from the origin."); } [Test] @@ -165,21 +195,34 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + /* TEST CODE */ - for (int i = 0; i < 17; ++i) { + for (int i = 0; i < 17; ++i) + { tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); } Assert.True(false, "DO NOT COME HERE since the limit of tensor size is 16"); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -193,18 +236,17 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("COVPARAM", "string, Tizen.MachineLearning.Inference.TensorType, int[]")] public void AddTensorInfo_CHECK_IndexOutOfRangeException_WITH_NAME() { + string TensorName = "InputTensorName"; var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - string TensorName = "InputTensorName"; - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + /* TEST CODE */ for (int i = 0; i < 17; ++i) { @@ -212,9 +254,21 @@ namespace Tizen.MachineLearning.Inference.Tests { } Assert.True(false, "DO NOT COME HERE since the limit of tensor size is 16"); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -227,20 +281,35 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")] public void GetTensorName_RETURN_VALUE() { + string inTensorName = "InputTensorName"; var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - string inTensorName = "InputTensorName"; - tensorsInfo.AddTensorInfo(inTensorName, TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(inTensorName, TensorType.UInt8, in_dim); - /* TEST CODE */ - string outTensorName = tensorsInfo.GetTensorName(0); - Assert.IsTrue(inTensorName == outTensorName, "The TensorInfo name is different from the origin."); + /* TEST CODE */ + string outTensorName = tensorsInfo.GetTensorName(0); + Assert.IsTrue(inTensorName == outTensorName, "The TensorInfo name is different from the origin."); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } [Test] @@ -252,24 +321,37 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")] public void GetTensorName_CHECK_IndexOutOfRangeException() { + string inTensorName = "InputTensorName"; var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - string inTensorName = "InputTensorName"; - tensorsInfo.AddTensorInfo(inTensorName, TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(inTensorName, TensorType.UInt8, in_dim); + + /* TEST CODE */ string outTensorName = tensorsInfo.GetTensorName(100); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -282,22 +364,37 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")] public void SetTensorName_RETURN_VALUE() { + string inTensorName = "InputTensorName"; var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - string inTensorName = "InputTensorName"; - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - /* TEST CODE */ - tensorsInfo.SetTensorName(0, inTensorName); + /* TEST CODE */ + tensorsInfo.SetTensorName(0, inTensorName); - string outTensorName = tensorsInfo.GetTensorName(0); - Assert.IsTrue(inTensorName == outTensorName, "The TensorInfo name is different from the origin."); + string outTensorName = tensorsInfo.GetTensorName(0); + Assert.IsTrue(inTensorName == outTensorName, "The TensorInfo name is different from the origin."); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } [Test] @@ -309,25 +406,37 @@ namespace Tizen.MachineLearning.Inference.Tests { [Property("AUTHOR", "Sangjung Woo, sangjung.woo@samsung.com")] public void SetTensorName_CHECK_IndexOutOfRangeException() { + string inTensorName = "InputTensorName"; var in_dim = new int[4] { 3, 224, 224, 1 }; Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - try { - string inTensorName = "InputTensorName"; + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); /* TEST CODE */ tensorsInfo.SetTensorName(100, inTensorName); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -344,20 +453,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); /* TEST CODE */ tensorsInfo.SetTensorName(0, null); } - catch (ArgumentException) + catch (Exception e) { - Assert.Pass("ArgumentException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -374,15 +495,30 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - /* TEST CODE */ - tensorsInfo.SetTensorType(0, TensorType.Float32); - Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.Float32, "The TensorType is not TensorType.Float32."); + /* TEST CODE */ + tensorsInfo.SetTensorType(0, TensorType.Float32); + Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.Float32, "The TensorType is not TensorType.Float32."); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } [Test] @@ -398,19 +534,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + + /* TEST CODE */ tensorsInfo.SetTensorType(100, TensorType.Float32); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -427,36 +576,36 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - foreach (TensorType type in Enum.GetValues(typeof(TensorType))) + try { - tensorsInfo.AddTensorInfo(type, in_dim); - } + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + foreach (TensorType type in Enum.GetValues(typeof(TensorType))) + { + tensorsInfo.AddTensorInfo(type, in_dim); + } - int i = 0; - foreach (TensorType type in Enum.GetValues(typeof(TensorType))) + int i = 0; + foreach (TensorType type in Enum.GetValues(typeof(TensorType))) + { + /* TEST CODE */ + Assert.IsTrue(tensorsInfo.GetTensorType(i++) == type, "The TensorType is different from the origin."); + } + } + catch (Exception e) { - /* TEST CODE */ - Assert.IsTrue(tensorsInfo.GetTensorType(i++) == type, "The TensorType is different from the origin."); - } - - /* - tensorsInfo.AddTensorInfo(TensorType.Int32, in_dim); - tensorsInfo.AddTensorInfo(TensorType.UInt32, in_dim); - tensorsInfo.AddTensorInfo(TensorType.Int16, in_dim); - tensorsInfo.AddTensorInfo(TensorType.UInt16, in_dim); - tensorsInfo.AddTensorInfo(TensorType.Int8, in_dim); - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - tensorsInfo.AddTensorInfo(TensorType.Float64, in_dim); - tensorsInfo.AddTensorInfo(TensorType.Float32, in_dim); - tensorsInfo.AddTensorInfo(TensorType.Int64, in_dim); - tensorsInfo.AddTensorInfo(TensorType.UInt64, in_dim); - - Assert.IsTrue(tensorsInfo.GetTensorType(0) == TensorType.Int32, "The TensorType is not TensorType.UInt8."); - */ + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } [Test] @@ -472,19 +621,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + + /* TEST CODE */ TensorType type = tensorsInfo.GetTensorType(100); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -505,21 +667,36 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_new_dim, "Should return int[] instance"); Assert.IsNotNull(in_new_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - /* TEST CODE */ - tensorsInfo.SetDimension(0, in_new_dim); - var in_res = tensorsInfo.GetDimension(0); - Assert.IsInstanceOf(in_res, "Should return int[] instance"); - Assert.IsNotNull(in_res, "Failed to create in_dim instance"); + /* TEST CODE */ + tensorsInfo.SetDimension(0, in_new_dim); + var in_res = tensorsInfo.GetDimension(0); + Assert.IsInstanceOf(in_res, "Should return int[] instance"); + Assert.IsNotNull(in_res, "Failed to create in_dim instance"); - for (int i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) + { + Assert.IsTrue(in_new_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + } + } + catch (Exception e) { - Assert.IsTrue(in_new_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -540,19 +717,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_new_dim, "Should return int[] instance"); Assert.IsNotNull(in_new_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + + /* TEST CODE */ tensorsInfo.SetDimension(100, in_new_dim); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -569,19 +759,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + + /* TEST CODE */ tensorsInfo.SetDimension(0, null); } - catch (ArgumentException) + catch (Exception e) { - Assert.Pass("ArgumentException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is ArgumentException) + { + Assert.Pass("ArgumentException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -598,17 +801,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - /* TEST CODE */ - int[] in_res = tensorsInfo.GetDimension(0); - for (int i = 0; i < 4; ++i) + /* TEST CODE */ + int[] in_res = tensorsInfo.GetDimension(0); + for (int i = 0; i < 4; ++i) + { + Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + } + } + catch (Exception e) { - Assert.IsTrue(in_dim[i] == in_res[i], "The dimension of Input Tensor is different from the origin."); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -625,19 +843,32 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - try { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + + /* TEST CODE */ var in_res = tensorsInfo.GetDimension(100); } - catch (IndexOutOfRangeException) + catch (Exception e) { - Assert.Pass("IndexOutOfRangeException: passed!"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else if (e is IndexOutOfRangeException) + { + Assert.Pass("IndexOutOfRangeException: passed!"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -658,27 +889,42 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(buffer_in, "Should return byte[] instance"); Assert.IsNotNull(buffer_in, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); - /* TEST CODE */ - var tensorsData = tensorsInfo.GetTensorsData(); - Assert.IsInstanceOf(tensorsData, "Should return TensorsData instance"); - Assert.IsNotNull(tensorsData, "Failed to create TensorsData instance"); + /* TEST CODE */ + var tensorsData = tensorsInfo.GetTensorsData(); + Assert.IsInstanceOf(tensorsData, "Should return TensorsData instance"); + Assert.IsNotNull(tensorsData, "Failed to create TensorsData instance"); - tensorsData.SetTensorData(0, buffer_in); + tensorsData.SetTensorData(0, buffer_in); - var buffer_out = tensorsData.GetTensorData(0); - Assert.IsInstanceOf(buffer_out, "buffer_out is not the type of byte[]."); - Assert.IsNotNull(buffer_out, "Fail to create buffer_out."); + var buffer_out = tensorsData.GetTensorData(0); + Assert.IsInstanceOf(buffer_out, "buffer_out is not the type of byte[]."); + Assert.IsNotNull(buffer_out, "Fail to create buffer_out."); - Assert.IsTrue(buffer_in.Length == buffer_out.Length, "The length of buffer_out payload is different from buffer_in."); - for (int i = 0; i < buffer_out.Length; ++i) + Assert.IsTrue(buffer_in.Length == buffer_out.Length, "The length of buffer_out payload is different from buffer_in."); + for (int i = 0; i < buffer_out.Length; ++i) + { + Assert.IsTrue(buffer_in[i] == buffer_out[i], "The value of buffer_in is different from that of buffer_out"); + } + } + catch (Exception e) { - Assert.IsTrue(buffer_in[i] == buffer_out[i], "The value of buffer_in is different from that of buffer_out"); + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } } } @@ -695,13 +941,28 @@ namespace Tizen.MachineLearning.Inference.Tests { Assert.IsInstanceOf(in_dim, "Should return int[] instance"); Assert.IsNotNull(in_dim, "Failed to create in_dim instance"); - var tensorsInfo = new TensorsInfo(); - Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); - Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - - tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + try + { + var tensorsInfo = new TensorsInfo(); + Assert.IsInstanceOf(tensorsInfo, "Should return TensorsInfo instance"); + Assert.IsNotNull(tensorsInfo, "Failed to create tensorsInfo instance"); - Assert.IsTrue(1 == tensorsInfo.Count, "The count of TensorsInfo should be 1."); + /* TEST CODE */ + tensorsInfo.AddTensorInfo(TensorType.UInt8, in_dim); + Assert.IsTrue(1 == tensorsInfo.Count, "The count of TensorsInfo should be 1."); + } + catch (Exception e) + { + if (e is NotSupportedException) + { + LogUtils.Write(LogUtils.DEBUG, LogUtils.TAG, "NotSupportedException occurs"); + Assert.IsTrue(_isMachineLeanringInferenceSupported == false, "Invalid NotSupportedException"); + } + else + { + Assert.True(false, e.Message); + } + } } } } -- 2.7.4