From: Suyeon Kim Date: Thu, 25 Apr 2024 06:41:00 +0000 (+0900) Subject: [common][ml] Update the test case of the Machine Learning domain and the dimension... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3f8337ed7435a01a96d8e7dc1c9fa216209ed047;p=test%2Ftct%2Fweb%2Fapi.git [common][ml] Update the test case of the Machine Learning domain and the dimension compare logic To support the higher rank of the ML model, the ML_TENSOR_RANK_LIMIT value of the ML API will be changed from 4 to 16. However, some test case of Web TCT assumes that ML_TENSOR_RANK_LIMIT is 4 and this causes the test case failure. This patch update the failed test cases. The ml-api will save '1' only if the user explicitly defined it. Values in the dimension array are treated 0 and 1 as same. Change-Id: If1af99ccb013d578ad4ca7111c6f366df3cfbba7 Signed-off-by: Suyeon Kim --- diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData.html b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData.html index e09ffc075..f6c1c1901 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData.html @@ -50,7 +50,7 @@ test(function () { assert_type(rawData1.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData1.data, data1, "Returned data should be correct"); - assert_array_equals(rawData1.shape, shape1, "Returned shape should be correct"); + assert_dimension_equals(rawData1.shape, shape1, "Returned shape should be correct"); assert_equals(rawData1.size, size1, "Returned size should be correct"); //param 1 rawData2 = tensorsData.getTensorRawData(0); @@ -58,7 +58,7 @@ test(function () { shape2 = new Array(3, 3, 1, 1); size2 = 18; assert_array_equals(rawData2.data, data2, "Returned data should be correct"); - assert_array_equals(rawData2.shape, shape2, "Returned shape should be correct"); + assert_dimension_equals(rawData2.shape, shape2, "Returned shape should be correct"); assert_equals(rawData2.size, size2, "Returned size should be correct"); //param 2 rawData3 = tensorsData.getTensorRawData(0, [1, 1]); @@ -66,7 +66,7 @@ test(function () { shape3 = new Array(2, 2, 1, 1); size3 = 8; assert_array_equals(rawData3.data, data3, "Returned data should be correct"); - assert_array_equals(rawData3.shape, shape3, "Returned shape should be correct"); + assert_dimension_equals(rawData3.shape, shape3, "Returned shape should be correct"); assert_equals(rawData3.size, size3, "Returned size should be correct"); tensorsData.dispose(); @@ -76,4 +76,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_location.html b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_location.html index 9d6bfb563..43422cd9e 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_location.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_location.html @@ -49,7 +49,7 @@ test(function () { assert_type(rawData.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData.data, data, "Returned data should be correct"); - assert_array_equals(rawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct"); assert_equals(rawData.size, size, "Returned size should be correct"); tensorsData.dispose(); tensorsInfo.dispose(); @@ -58,4 +58,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_size.html b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_size.html index 2b5def7f3..e6c06895d 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_size.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_size.html @@ -49,7 +49,7 @@ test(function () { assert_type(rawData.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData.data, data, "Returned data should be correct"); - assert_array_equals(rawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct"); assert_equals(rawData.size, size, "Returned size should be correct"); tensorsData.dispose(); tensorsInfo.dispose(); @@ -58,4 +58,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData.html b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData.html index 4220c6d87..6e53a1cb4 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData.html @@ -51,7 +51,7 @@ test(function () { assert_type(rawData.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData.data, data, "Returned data should be correct"); - assert_array_equals(rawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct"); assert_equals(rawData.size, size, "Returned size should be correct"); tensorsData.dispose(); @@ -60,4 +60,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_location.html b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_location.html index 8fc690e6c..0e449e0aa 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_location.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_location.html @@ -51,13 +51,13 @@ test(function () { assert_type(rawData.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData.data, data, "Returned data should be correct"); - assert_array_equals(rawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct"); assert_equals(rawData.size, size, "Returned size should be correct"); - + tensorsData.dispose(); tensorsInfo.dispose(); }, document.title); - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_size.html b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_size.html index e899367ca..050080513 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_size.html +++ b/common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_size.html @@ -51,13 +51,13 @@ test(function () { assert_type(rawData.size, "number", "type of the returned value is not a byte"); assert_array_equals(rawData.data, data, "Returned data should be correct"); - assert_array_equals(rawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct"); assert_equals(rawData.size, size, "Returned size should be correct"); - + tensorsData.dispose(); tensorsInfo.dispose(); }, document.title); - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsInfo_addTensorInfo.html b/common/tct-ml-tizen-tests/ml/TensorsInfo_addTensorInfo.html index d1d238dba..2b4ff708b 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsInfo_addTensorInfo.html +++ b/common/tct-ml-tizen-tests/ml/TensorsInfo_addTensorInfo.html @@ -41,7 +41,7 @@ test(function () { retValue = tensorsInfo.addTensorInfo("tensor", "UINT8", [4, 4]); assert_type(retValue, "long", "type of the returned value is not long type"); assert_equals(retValue, 0, "Returned data should be right index"); - + TensorName = tensorsInfo.getTensorName(0); assert_type(TensorName, "string", "type of the returned value is not a domstring"); assert_equals(TensorName, "tensor", "Returned data should be correct"); @@ -52,7 +52,7 @@ test(function () { Dimensions = tensorsInfo.getDimensions(0); Dimensions1 = new Array(4, 4, 1, 1); - assert_array_equals(Dimensions, Dimensions1, "getDimensions of tensor in tensorsInfo incorrect"); + assert_dimension_equals(Dimensions, Dimensions1, "getDimensions of tensor in tensorsInfo incorrect"); retValue = tensorsInfo.addTensorInfo("tensor", "UINT8", [4, 4, 4, 4, 4]); assert_type(retValue, "long", "type of the returned value is not long type"); @@ -62,4 +62,4 @@ test(function () { }, document.title); - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsInfo_getDimensions.html b/common/tct-ml-tizen-tests/ml/TensorsInfo_getDimensions.html index a292a7bf2..646addc8f 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsInfo_getDimensions.html +++ b/common/tct-ml-tizen-tests/ml/TensorsInfo_getDimensions.html @@ -40,19 +40,18 @@ test(function () { retValue1 = tensorsInfo.getDimensions(0); dismension1 = new Array(1, 1, 1, 1); assert_type(retValue1, "array", "returned value should be long[] type"); - assert_array_equals(retValue1, dismension1, "returned value should be correct value"); - //dimensions Array with tensor's dimensions to be set. Each value determines number of elements in each dimension. Valid array contains only postive numbers. - //The maximum supported rank is 4. Values on bigger indexes will be discarded. In case when dimensions' length is less than 4, - //remaining values will be filled with 1. - tensorsInfo.addTensorInfo("tensor2", "UINT8", [3, 3, 3, 3, 3, 3, 3]); + assert_dimension_equals(retValue1, dismension1, "returned value should be correct value"); + //dimensions Array with tensor's dimensions to be set. Each value determines number of elements in each dimension. Valid array contains only postive numbers. + //The maximum supported rank is ML_TENSOR_RANK_LIMIT (16 since Tizen 7.5, old rank limit till Tizen 7.0 is 4). Values on bigger indexes will be discarded. + tensorsInfo.addTensorInfo("tensor2", "UINT8", [3, 3, 3, 3, 1, 1, 1]); retValue2 = tensorsInfo.getDimensions(1); dismension2 = new Array(3, 3, 3, 3); assert_type(retValue2, "array", "returned value should be long[] type"); - assert_array_equals(retValue2, dismension2, "returned value should be correct value"); + assert_dimension_equals(retValue2, dismension2, "returned value should be correct value"); - tensorsInfo.dispose(); -}, document.title); + tensorsInfo.dispose(); +}, document.title); - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/TensorsInfo_setDimensions.html b/common/tct-ml-tizen-tests/ml/TensorsInfo_setDimensions.html index 6f28abe77..435ede6bc 100755 --- a/common/tct-ml-tizen-tests/ml/TensorsInfo_setDimensions.html +++ b/common/tct-ml-tizen-tests/ml/TensorsInfo_setDimensions.html @@ -34,22 +34,22 @@ Authors: //==== PRIORITY P1 //==== TEST_CRITERIA MR MAST test(function () { - var tensorsInfo, retValue, Dimensions1, Dimensions2, Dimensions3, Dimensions4; + var tensorsInfo, retValue, Dimensions1, Dimensions2, Dimensions3, Dimensions4; tensorsInfo = new tizen.ml.TensorsInfo(); tensorsInfo.addTensorInfo("tensor1", "UINT8", [2, 2]); Dimensions1 = tensorsInfo.getDimensions(0); Dimensions2 = new Array(2, 2, 1, 1); - assert_array_equals(Dimensions1, Dimensions2, "getDimensions of tensor in tensorsInfo incorrect"); - + assert_dimension_equals(Dimensions1, Dimensions2, "getDimensions of tensor in tensorsInfo incorrect"); + retValue = tensorsInfo.setDimensions(0, [4, 4, 4, 4]); assert_type(retValue, "undefined", "return value should be unidefined"); Dimensions3 = tensorsInfo.getDimensions(0); Dimensions4 = new Array(4, 4, 4, 4); - assert_array_equals(Dimensions3, Dimensions4, "getDimensions of tensor in tensorsInfo incorrect"); + assert_dimension_equals(Dimensions3, Dimensions4, "getDimensions of tensor in tensorsInfo incorrect"); tensorsInfo.dispose(); - -}, document.title); + +}, document.title); - \ No newline at end of file + diff --git a/common/tct-ml-tizen-tests/ml/support/unitcommon.js b/common/tct-ml-tizen-tests/ml/support/unitcommon.js index d7334f17a..3c800cbdf 100755 --- a/common/tct-ml-tizen-tests/ml/support/unitcommon.js +++ b/common/tct-ml-tizen-tests/ml/support/unitcommon.js @@ -316,6 +316,30 @@ function assert_type(obj, type, description) { } } +function assert_dimension_equals(dim1, dim2, description) { + var i, len, len_larger, dim_larger; + + assert_type(dim1, 'array', description + " - dim1 is not array."); + assert_type(dim2, 'array', description + " - dim2 is not array."); + + if (dim1.length > dim2.length) { + dim_larger = dim1; + len_larger = dim1.length; + len = dim2.length; + } else { + dim_larger = dim2; + len_larger = dim2.length; + len = dim1.length; + } + + for (i = 0; i < len; i++) { + assert_true(dim1[i] == dim2[i], description + " - dimension is not equal."); + } + for (i = len; i < len_larger; i++) { + assert_true(dim_larger[i] == 0 || dim_larger[i] == 1, description + " - dimension is not equal."); + } +} + function register_type(alias, type_spec) { _registered_types[alias] = type_spec; } diff --git a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/MachineLearningSingle_openModel_with_isDynamicMode.html b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/MachineLearningSingle_openModel_with_isDynamicMode.html index f759af527..4e98f05b5 100755 --- a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/MachineLearningSingle_openModel_with_isDynamicMode.html +++ b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/MachineLearningSingle_openModel_with_isDynamicMode.html @@ -57,8 +57,8 @@ test(function () { retValue1 = model.output.getDimensions(0); dismension1 = new Array(3, 1, 1, 1); assert_type(retValue1, "array", "returned value should be long[] type"); - assert_array_equals(retValue1, dismension1, "returned value should be correct value"); - + assert_dimension_equals(retValue1, dismension1, "returned value should be correct value"); + //change input2 //inputTI3 = new tizen.ml.TensorsInfo(); //inputTI3.addTensorInfo("tensor3", "FLOAT32", [2, 1, 1, 1]); @@ -68,7 +68,7 @@ test(function () { //retValue2 = model.output.getDimensions(0); //dismension2 = new Array(2, 1, 1, 1); //assert_type(retValue2, "array", "returned value should be long[] type"); - //assert_array_equals(retValue2, dismension2, "returned value should be correct value"); + //assert_dimension_equals(retValue2, dismension2, "returned value should be correct value"); tensorsDataOut1.dispose(); tensorsDataOut2.dispose(); tensorsData1.dispose(); @@ -81,4 +81,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/SingleShot_invoke.html b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/SingleShot_invoke.html index b460be057..a77a9c766 100755 --- a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/SingleShot_invoke.html +++ b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/SingleShot_invoke.html @@ -53,9 +53,9 @@ test(function () { shape = new Array(1001, 1, 1, 1); size = 1001; //assert_equals(tensorRawData.data, data, "Returned data should be correct"); - assert_array_equals(tensorRawData.shape, shape, "Returned shape should be correct"); + assert_dimension_equals(tensorRawData.shape, shape, "Returned shape should be correct"); assert_equals(tensorRawData.size, size, "Returned size should be correct"); - + tensorsDataOut.dispose(); tensorsData.dispose(); tensorsInfo.dispose(); @@ -64,4 +64,4 @@ test(function () { - \ No newline at end of file + diff --git a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/support/unitcommon.js b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/support/unitcommon.js index 6a9725e88..48bedf7e6 100755 --- a/common/tct-mlsingleshot-tizen-tests/mlsingleshot/support/unitcommon.js +++ b/common/tct-mlsingleshot-tizen-tests/mlsingleshot/support/unitcommon.js @@ -317,6 +317,32 @@ function assert_type(obj, type, description) { } } +function assert_dimension_equals(dim1, dim2, description) { + var i, len, len_larger, dim_larger; + + assert_type(dim1, 'array', description + " - dim1 is not array."); + assert_type(dim2, 'array', description + " - dim2 is not array."); + + if (dim1.length > dim2.length) { + dim_larger = dim1; + len_larger = dim1.length; + len = dim2.length; + } else { + dim_larger = dim2; + len_larger = dim2.length; + len = dim1.length; + } + + for (i = 0; i < len; i++) { + if (dim1[i] != dim2[i]) { + assert_true(dim1[i] <= 1 && dim2[i] <= 1, description + " - dimension is not equal."); + } + } + for (i = len; i < len_larger; i++) { + assert_true(dim_larger[i] == 0 || dim_larger[i] == 1, description + " - dimension is not equal."); + } +} + function register_type(alias, type_spec) { _registered_types[alias] = type_spec; }