2 # Copyright (C) 2017 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
25 i0 = Input("i0", "TENSOR_QUANT8_ASYMM", "{%d, %d, %d, %d}, 0.5f, 0" % (bat, row, col, chn))
31 stride = Int32Scalar("stride", std)
32 filt = Int32Scalar("filter", flt)
33 padding = Int32Scalar("padding", pad)
34 act2 = Int32Scalar("relu1_activation", 2)
35 output_row = (row + 2 * pad - flt + std) // std
36 output_col = (col + 2 * pad - flt + std) // std
38 output = Output("output", "TENSOR_QUANT8_ASYMM",
39 "{%d, %d, %d, %d}, 0.5f, 0" % (bat, output_row, output_col, chn))
41 model = model.Operation(
42 "MAX_POOL_2D", i0, padding, padding, padding, padding, stride, stride, filt, filt, act2).To(output)
44 # Example 1. Input in operand 0
45 input_range = bat * row * col * chn
46 input_values = (lambda s = std, r = input_range: [x % s + 1 for x in range(r)])()
47 input0 = {i0: input_values}
48 output_range = bat * output_row * output_col * chn
49 output_values = (lambda r = output_range: [ 2 for _ in range(r)])()
50 output0 = {output: output_values}
52 # Instantiate an example
53 Example((input0, output0))