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 = Model() 18 i1 = Input("input", "TENSOR_FLOAT32", "{1, 1, 1, 6}") 19 radius = Int32Scalar("radius", 20) 20 bias = Float32Scalar("bias", 0.) 21 alpha = Float32Scalar("alpha", 1.) 22 beta = Float32Scalar("beta", .5) 23 output = Output("output", "TENSOR_FLOAT32", "{1, 1, 1, 6}") 24 25 model = model.Operation("LOCAL_RESPONSE_NORMALIZATION", i1, radius, bias, alpha, beta).To(output) 26 model = model.RelaxedExecution(True) 27 28 # Example 1. Input in operand 0, 29 input0 = {i1: # input 0 30 [-1.1, .6, .7, 1.2, -.7, .1]} 31 32 output0 = {output: # output 0 33 [-.55, .3, .35, .6, -.35, .05]} 34 35 # Instantiate an example 36 Example((input0, output0)) 37