Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / tests / nnapi / specs / V1_2 / logical_or_dynamic_nnfw.py
1 #
2 # Copyright (C) 2018 The Android Open Source Project
3 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
18 # refer to tanh_v1_dynamic.mod.py about the structore
19
20 # This adds reshape as the first op in a model and
21 # returns output of reshape, which is dynamic tensor
22
23
24 import dynamic_tensor
25
26 model = Model()
27
28 model_input_shape = [2, 1, 2, 2]
29
30 dynamic_layer = dynamic_tensor.DynamicInputGenerator(model, model_input_shape, "TENSOR_BOOL8")
31
32 test_node_input = dynamic_layer.getTestNodeInput()
33
34 # model
35 i2 = Input("op2", "TENSOR_BOOL8", "{2, 1, 2, 2}")
36 t1 = Internal("op3", "TENSOR_BOOL8", "{}") # result of first LOGICAL_OR
37 act = Int32Scalar("act", 0) # scalar activation
38 o1 = Output("op3", "TENSOR_BOOL8", "{2, 1, 2, 2}")
39
40 model = model.Operation("LOGICAL_OR", test_node_input, i2, act).To(t1) # first add
41 model = model.Operation("LOGICAL_OR", t1, i2, act).To(o1)              # second add
42
43 model_input1_data = [False, False, True, True, False, True, False, True]
44 model_input2_data = [False, True, False, True, False, False, True, True]
45 model_output_data = [False, True, True, True, False, True, True, True]
46
47 Example({
48     dynamic_layer.getModelInput(): model_input1_data,
49     dynamic_layer.getShapeInput(): model_input1_shape,
50     i2 : model_input2_data,
51
52     model_output: model_output_data,
53 })