1c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#
2c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# Copyright (C) 2017 The Android Open Source Project
3c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#
4c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# Licensed under the Apache License, Version 2.0 (the "License");
5c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# you may not use this file except in compliance with the License.
6c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# You may obtain a copy of the License at
7c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#
8c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#      http://www.apache.org/licenses/LICENSE-2.0
9c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#
10c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# Unless required by applicable law or agreed to in writing, software
11c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# distributed under the License is distributed on an "AS IS" BASIS,
12c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# See the License for the specific language governing permissions and
14c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# limitations under the License.
15c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang#
16c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang
17c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangmodel = Model()
18c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangi1 = Input("op1", "TENSOR_QUANT8_ASYMM", "{1, 2, 2, 2}, 0.5f, 0")
19297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungf1 = Parameter("op2", "TENSOR_QUANT8_ASYMM", "{1, 2, 2, 2}, 0.5f, 0", [2, 4,  2, 0,  2, 2,  2, 0])
20297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sungb1 = Parameter("op3", "TENSOR_INT32", "{2}, 0.25f, 0", [0, 0])
21c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangpad0 = Int32Scalar("pad0", 0)
22c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangact = Int32Scalar("act", 0)
23c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangstride = Int32Scalar("stride", 1)
24c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangcm = Int32Scalar("channelMultiplier", 1)
25c96b526122230f552e5bbb96d4bd0497f50c5c91gfanoutput = Output("op4", "TENSOR_QUANT8_ASYMM", "{1,1,1,2}, 1.f, 0")
26c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang
27c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangmodel = model.Operation("DEPTHWISE_CONV_2D",
28c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang                        i1, f1, b1,
29c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang                        pad0, pad0, pad0, pad0,
30c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang                        stride, stride,
31c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang                        cm, act).To(output)
32c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang
33c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# Example 1. Input in operand 0,
34c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwanginput0 = {i1: # input 0
35297c580a2d2da2839d936437bf4e3a4c64034950I-Jui (Ray) Sung          [4, 16, 4, 32, 4, 64, 4, 128]}
36c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# (i1 (depthconv) f1)
37c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangoutput0 = {output: # output 0
38c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang           [8, 48]}
39c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang
40c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwang# Instantiate an example
41c715e9dcaab69a0817fd79ebcfb7011c53ff0c13leozwangExample((input0, output0))
42