Imported Upstream version 1.4.0
[platform/core/ml/nnfw.git] / tests / nnapi / specs / skip / V1_1 / avg_pool_float_4_relaxed.mod.py
1 #
2 # Copyright (C) 2018 The Android Open Source Project
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 # model
18 model = Model()
19
20 bat = 5
21 row = 52
22 col = 60
23 chn = 3
24
25 i0 = Input("i0", "TENSOR_FLOAT32", "{%d, %d, %d, %d}" % (bat, row, col, chn))
26
27 std = 5
28 flt = 100
29 pad = 50
30
31 stride = Int32Scalar("stride", std)
32 filt = Int32Scalar("filter", flt)
33 padding = Int32Scalar("padding", pad)
34 act3 = Int32Scalar("relu6_activation", 3)
35 output_row = (row + 2 * pad - flt + std) // std
36 output_col = (col + 2 * pad - flt + std) // std
37
38 output = Output("output", "TENSOR_FLOAT32",
39                 "{%d, %d, %d, %d}" % (bat, output_row, output_col, chn))
40
41 model = model.Operation(
42     "AVERAGE_POOL_2D", i0, padding, padding, padding, padding, stride, stride, filt, filt, act3).To(output)
43 model = model.RelaxedExecution(True)
44
45 # Example 1. Input in operand 0,
46 input_values = [10 for _ in range(bat * row * col * chn)]
47 input0 = {i0: input_values}
48 output_values = [6 for _ in range(bat * output_row * output_col * chn)]
49 output0 = {output: output_values}
50
51 # Instantiate an example
52 Example((input0, output0))