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);
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]);
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();
</script>
</body>
-</html>
\ No newline at end of file
+</html>
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
\r
</script>\r
</body>\r
-</html>
\ No newline at end of file
+</html>\r
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();
</script>
</body>
-</html>
\ No newline at end of file
+</html>
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();
</script>
</body>
-</html>
\ No newline at end of file
+</html>
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
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>
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");
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");
}, document.title);
</script>
</body>
-</html>
\ No newline at end of file
+</html>
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>
//==== 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>
}
}
+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;
}
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]);
//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();
</script>
</body>
-</html>
\ No newline at end of file
+</html>
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();
</script>
</body>
-</html>
\ No newline at end of file
+</html>
}
}
+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;
}