f759af527ea48690ae164d1366f0d39d3fb8cb25
[test/tct/web/api.git] /
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2021 Samsung Electronics Co., Ltd.
4
5 Licensed under the Apache License, Version 2.0 (the License);
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16
17 Authors:
18         Chen Chen <chen89.chen@samsung.com>
19
20 -->
21 <html>
22 <head>
23 <title>MachineLearningSingle_openModel_with_isDynamicMode</title>
24 <meta charset="utf-8"/>
25 <script src="support/unitcommon.js"></script>
26 <script src="support/mlsinglecommon.js"></script>
27 </head>
28 <body>
29 <div id="log"></div>
30 <script>
31 //==== TEST: MachineLearningSingle_openModel_with_isDynamicMode
32 //==== LABEL Check if MachineLearningSingle:openModel() method with DynamicMode works properly with optional argument
33 //==== SPEC Tizen Web API:TBD:MLSingleShot:MachineLearningSingle:openModel M
34 //==== SPEC_URL TBD
35 //==== PRIORITY P1
36 //==== TEST_CRITERIA MOA MR MAST
37 test(function () {
38     var model, inputTI1, inputTI2, tensorsData1, tensorsData2, tensorsDataOut1, tensorsDataOut2;
39
40     model = tizen.ml.single.openModel(
41         TENSORFLOW_LITE_DYNAMICMODE_PATH, null, null, "TENSORFLOW_LITE", "ANY", true);
42     assert_type(model, "object", "the return value should be object type");
43
44     inputTI1 = new tizen.ml.TensorsInfo();
45     inputTI1.addTensorInfo("tensor1", "FLOAT32", [1, 1, 1, 1]);
46     tensorsData1 = inputTI1.getTensorsData();
47
48     tensorsDataOut1 = model.invoke(tensorsData1);
49
50     inputTI2 = new tizen.ml.TensorsInfo();
51     inputTI2.addTensorInfo("tensor2", "FLOAT32", [3, 1, 1, 1]);
52     tensorsData2 = inputTI2.getTensorsData();
53     //change input1
54
55     tensorsDataOut2 = model.invoke(tensorsData2);
56
57     retValue1 = model.output.getDimensions(0);
58     dismension1 = new Array(3, 1, 1, 1);
59     assert_type(retValue1, "array", "returned value should be long[] type");
60     assert_array_equals(retValue1, dismension1, "returned value should be correct value");
61     
62     //change input2
63     //inputTI3 = new tizen.ml.TensorsInfo();
64     //inputTI3.addTensorInfo("tensor3", "FLOAT32", [2, 1, 1, 1]);
65
66     //model.input = inputTI3;
67
68     //retValue2 = model.output.getDimensions(0);
69     //dismension2 = new Array(2, 1, 1, 1);
70     //assert_type(retValue2, "array", "returned value should be long[] type");
71     //assert_array_equals(retValue2, dismension2, "returned value should be correct value");
72     tensorsDataOut1.dispose();
73     tensorsDataOut2.dispose();
74     tensorsData1.dispose();
75     tensorsData2.dispose();
76     inputTI1.dispose();
77     inputTI2.dispose();
78     //inputTI3.dispose();
79     model.close();
80 }, document.title);
81
82 </script>
83 </body>
84 </html>