1297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#
2297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Copyright (C) 2017 The Android Open Source Project
3297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#
4297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Licensed under the Apache License, Version 2.0 (the "License");
5297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# you may not use this file except in compliance with the License.
6297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# You may obtain a copy of the License at
7297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#
8297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#      http://www.apache.org/licenses/LICENSE-2.0
9297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#
10297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Unless required by applicable law or agreed to in writing, software
11297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# distributed under the License is distributed on an "AS IS" BASIS,
12297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# See the License for the specific language governing permissions and
14297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# limitations under the License.
15297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung#
16297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung
17297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungmodel = Model()
18297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungin0 = Input("op1", "TENSOR_QUANT8_ASYMM", "{1, 5}, 0.2, 0") # batch = 1, input_size = 5
19297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungweights = Input("op2", "TENSOR_QUANT8_ASYMM", "{1, 5}, 0.2, 0") # num_units = 1, input_size = 5
20297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungbias = Input("b0", "TENSOR_INT32", "{1}, 0.04, 0")
21297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungout0 = Output("op3", "TENSOR_QUANT8_ASYMM", "{1, 1}, 1.f, 0") # batch = 1, number_units = 1
22297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungact = Int32Scalar("act", 0)
23297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungmodel = model.Operation("FULLY_CONNECTED", in0, weights, bias, act).To(out0)
24297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung
25297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Example 1. Input in operand 0,
26297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sunginput0 = {in0: # input 0
27297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          [10, 10, 10, 10, 10],
28297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          weights:
29297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          [10, 20, 20, 20, 10],
30297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          bias:
31297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          [10]}
32297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungoutput0 = {out0: # output 0
33297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung           [32]}
34297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung
35297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung# Instantiate an example
36297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) SungExample((input0, output0))
37