[common][ml] Update the test case of the Machine Learning domain and the dimension... 09/310309/1
authorSuyeon Kim <suyeon5.kim@samsung.com>
Thu, 25 Apr 2024 06:41:00 +0000 (15:41 +0900)
committerSuyeon Kim <suyeon5.kim@samsung.com>
Thu, 25 Apr 2024 06:41:00 +0000 (15:41 +0900)
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 <suyeon5.kim@samsung.com>
13 files changed:
common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData.html
common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_location.html
common/tct-ml-tizen-tests/ml/TensorsData_getTensorRawData_with_size.html
common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData.html
common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_location.html
common/tct-ml-tizen-tests/ml/TensorsData_setTensorRawData_with_size.html
common/tct-ml-tizen-tests/ml/TensorsInfo_addTensorInfo.html
common/tct-ml-tizen-tests/ml/TensorsInfo_getDimensions.html
common/tct-ml-tizen-tests/ml/TensorsInfo_setDimensions.html
common/tct-ml-tizen-tests/ml/support/unitcommon.js
common/tct-mlsingleshot-tizen-tests/mlsingleshot/MachineLearningSingle_openModel_with_isDynamicMode.html
common/tct-mlsingleshot-tizen-tests/mlsingleshot/SingleShot_invoke.html
common/tct-mlsingleshot-tizen-tests/mlsingleshot/support/unitcommon.js

index e09ffc07597dc0fb5369061d1df2efa4400377e6..f6c1c19011386f124f896323cbe0ae9e68dcefd0 100755 (executable)
@@ -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 () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 9d6bfb563a4ab84b2d1e9bca043ffdc5578ddb82..43422cd9ea5da499b98c10a3abbad5b086d5df6e 100755 (executable)
@@ -49,7 +49,7 @@ test(function () {
     assert_type(rawData.size, "number", "type of the returned value is not a byte");\r
 \r
     assert_array_equals(rawData.data, data, "Returned data should be correct");\r
-    assert_array_equals(rawData.shape, shape, "Returned shape should be correct");\r
+    assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct");\r
     assert_equals(rawData.size, size, "Returned size should be correct");\r
     tensorsData.dispose();\r
     tensorsInfo.dispose();\r
@@ -58,4 +58,4 @@ test(function () {
 \r
 </script>\r
 </body>\r
-</html>
\ No newline at end of file
+</html>\r
index 2b5def7f3ecc792e002e7acfbced1519c74d5827..e6c06895d09cbb7790203fba8cdae1b0435c2f45 100755 (executable)
@@ -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 () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 4220c6d879108846c589efa6f6c770e4c918fff8..6e53a1cb4890c429871ef638082322654a4b04cc 100755 (executable)
@@ -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 () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 8fc690e6cd2aad96779040efd9331634db6ab7b2..0e449e0aa02d1420a5e2630aadd66b3f6abcbb48 100755 (executable)
@@ -51,13 +51,13 @@ test(function () {
     assert_type(rawData.size, "number", "type of the returned value is not a byte");\r
 \r
     assert_array_equals(rawData.data, data, "Returned data should be correct");\r
-    assert_array_equals(rawData.shape, shape, "Returned shape should be correct");\r
+    assert_dimension_equals(rawData.shape, shape, "Returned shape should be correct");\r
     assert_equals(rawData.size, size, "Returned size should be correct");\r
-    \r
+\r
     tensorsData.dispose();\r
     tensorsInfo.dispose();\r
 }, document.title);\r
 \r
 </script>\r
 </body>\r
-</html>
\ No newline at end of file
+</html>\r
index e899367ca0d13be0f9836e4a02f6f44624da3bbb..050080513c7c3b276d560b75327dcadb281677fb 100755 (executable)
@@ -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);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index d1d238dbaaca714ac7c76676837810464c480008..2b4ff708ba48e8b25f8995314c65bf04290c6a6d 100755 (executable)
@@ -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);
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index a292a7bf2b9e0805ed0dc6f9bef6fdb80f0d063a..646addc8fb50c2e523dc7cd8765ee0e896903d31 100755 (executable)
@@ -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);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 6f28abe77f2f444ffafbc9001214af1840ad11d0..435ede6bcd1dd39d672f6820cbcce4970c6a1557 100755 (executable)
@@ -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);
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index d7334f17a233f48a1e8a4bc2434bcd027961f7b5..3c800cbdff76f07f5ca24ea5560dff419b4df7da 100755 (executable)
@@ -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;
 }
index f759af527ea48690ae164d1366f0d39d3fb8cb25..4e98f05b55fd09422bba96959502a87e29eaa22a 100755 (executable)
@@ -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 () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index b460be057f284c7687fc09f5ff81eb6ca1e6afae..a77a9c7662200bfce4abc2afe2ac57e57ba28dc3 100755 (executable)
@@ -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 () {
 
 </script>
 </body>
-</html>
\ No newline at end of file
+</html>
index 6a9725e88164fc4e1e5747f60913a6e55cef8ac3..48bedf7e6eacf435df74a34162dffa2e2fb07a9a 100755 (executable)
@@ -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;
 }