1aba934df113efb34d727796b3ae959aebb9eb080leozwang# 2aba934df113efb34d727796b3ae959aebb9eb080leozwang# Copyright (C) 2017 The Android Open Source Project 3aba934df113efb34d727796b3ae959aebb9eb080leozwang# 4aba934df113efb34d727796b3ae959aebb9eb080leozwang# Licensed under the Apache License, Version 2.0 (the "License"); 5aba934df113efb34d727796b3ae959aebb9eb080leozwang# you may not use this file except in compliance with the License. 6aba934df113efb34d727796b3ae959aebb9eb080leozwang# You may obtain a copy of the License at 7aba934df113efb34d727796b3ae959aebb9eb080leozwang# 8aba934df113efb34d727796b3ae959aebb9eb080leozwang# http://www.apache.org/licenses/LICENSE-2.0 9aba934df113efb34d727796b3ae959aebb9eb080leozwang# 10aba934df113efb34d727796b3ae959aebb9eb080leozwang# Unless required by applicable law or agreed to in writing, software 11aba934df113efb34d727796b3ae959aebb9eb080leozwang# distributed under the License is distributed on an "AS IS" BASIS, 12aba934df113efb34d727796b3ae959aebb9eb080leozwang# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13aba934df113efb34d727796b3ae959aebb9eb080leozwang# See the License for the specific language governing permissions and 14aba934df113efb34d727796b3ae959aebb9eb080leozwang# limitations under the License. 15aba934df113efb34d727796b3ae959aebb9eb080leozwang# 16aba934df113efb34d727796b3ae959aebb9eb080leozwang 17aba934df113efb34d727796b3ae959aebb9eb080leozwangmodel = Model() 18aba934df113efb34d727796b3ae959aebb9eb080leozwangin0 = Input("op1", "TENSOR_QUANT8_ASYMM", "{1, 5}, 0.2, 0") # batch = 1, input_size = 5 19297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungweights = Parameter("op2", "TENSOR_QUANT8_ASYMM", "{1, 5}, 0.2, 0", [10, 20, 20, 20, 10]) # num_units = 1, input_size = 5 20297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungbias = Parameter("b0", "TENSOR_INT32", "{1}, 0.04, 0", [10]) 21aba934df113efb34d727796b3ae959aebb9eb080leozwangout0 = Output("op3", "TENSOR_QUANT8_ASYMM", "{1, 1}, 1.f, 0") # batch = 1, number_units = 1 22aba934df113efb34d727796b3ae959aebb9eb080leozwangact = Int32Scalar("act", 0) 23aba934df113efb34d727796b3ae959aebb9eb080leozwangmodel = model.Operation("FULLY_CONNECTED", in0, weights, bias, act).To(out0) 24aba934df113efb34d727796b3ae959aebb9eb080leozwang 25aba934df113efb34d727796b3ae959aebb9eb080leozwang# Example 1. Input in operand 0, 26aba934df113efb34d727796b3ae959aebb9eb080leozwanginput0 = {in0: # input 0 27297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung [10, 10, 10, 10, 10]} 28aba934df113efb34d727796b3ae959aebb9eb080leozwangoutput0 = {out0: # output 0 29aba934df113efb34d727796b3ae959aebb9eb080leozwang [32]} 30aba934df113efb34d727796b3ae959aebb9eb080leozwang 31aba934df113efb34d727796b3ae959aebb9eb080leozwang# Instantiate an example 32aba934df113efb34d727796b3ae959aebb9eb080leozwangExample((input0, output0)) 33