Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / tests / nnapi / specs / skip / V1_1 / svdf_relaxed.mod.py
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 batches = 2
18 features = 4
19 rank = 1
20 units = int(features / rank)
21 input_size = 3
22 memory_size = 10
23
24 model = Model()
25
26 input = Input("input", "TENSOR_FLOAT32", "{%d, %d}" % (batches, input_size))
27 weights_feature = Input("weights_feature", "TENSOR_FLOAT32", "{%d, %d}" % (features, input_size))
28 weights_time = Input("weights_time", "TENSOR_FLOAT32", "{%d, %d}" % (features, memory_size))
29 bias = Input("bias", "TENSOR_FLOAT32", "{%d}" % (units))
30 state_in = Input("state_in", "TENSOR_FLOAT32", "{%d, %d}" % (batches, memory_size*features))
31 rank_param = Int32Scalar("rank_param", rank)
32 activation_param = Int32Scalar("activation_param", 0)
33 state_out = IgnoredOutput("state_out", "TENSOR_FLOAT32", "{%d, %d}" % (batches, memory_size*features))
34 output = Output("output", "TENSOR_FLOAT32", "{%d, %d}" % (batches, units))
35
36 model = model.Operation("SVDF", input, weights_feature, weights_time, bias, state_in,
37                         rank_param, activation_param).To([state_out, output])
38 model = model.RelaxedExecution(True)
39
40 input0 = {
41     input: [],
42     weights_feature: [
43         -0.31930989, -0.36118156, 0.0079667, 0.37613347,
44       0.22197971, 0.12416199, 0.27901134, 0.27557442,
45       0.3905206, -0.36137494, -0.06634006, -0.10640851
46     ],
47     weights_time: [
48         -0.31930989, 0.37613347,  0.27901134,  -0.36137494, -0.36118156,
49       0.22197971,  0.27557442,  -0.06634006, 0.0079667,   0.12416199,
50
51        0.3905206,   -0.10640851, -0.0976817,  0.15294972,  0.39635518,
52       -0.02702999, 0.39296314,  0.15785322,  0.21931258,  0.31053296,
53
54        -0.36916667, 0.38031587,  -0.21580373, 0.27072677,  0.23622236,
55       0.34936687,  0.18174365,  0.35907319,  -0.17493086, 0.324846,
56
57        -0.10781813, 0.27201805,  0.14324132,  -0.23681851, -0.27115166,
58       -0.01580888, -0.14943552, 0.15465137,  0.09784451,  -0.0337657
59     ],
60     bias: [],
61     state_in: [0 for _ in range(batches * memory_size * features)],
62 }
63
64 test_inputs = [
65     0.12609188,  -0.46347019, -0.89598465,
66     0.12609188,  -0.46347019, -0.89598465,
67
68     0.14278367,  -1.64410412, -0.75222826,
69     0.14278367,  -1.64410412, -0.75222826,
70
71     0.49837467,  0.19278903,  0.26584083,
72     0.49837467,  0.19278903,  0.26584083,
73
74     -0.11186574, 0.13164264,  -0.05349274,
75     -0.11186574, 0.13164264,  -0.05349274,
76
77     -0.68892461, 0.37783599,  0.18263303,
78     -0.68892461, 0.37783599,  0.18263303,
79
80     -0.81299269, -0.86831826, 1.43940818,
81     -0.81299269, -0.86831826, 1.43940818,
82
83     -1.45006323, -0.82251364, -1.69082689,
84     -1.45006323, -0.82251364, -1.69082689,
85
86     0.03966608,  -0.24936394, -0.77526885,
87     0.03966608,  -0.24936394, -0.77526885,
88
89     0.11771342,  -0.23761693, -0.65898693,
90     0.11771342,  -0.23761693, -0.65898693,
91
92     -0.89477462, 1.67204106,  -0.53235275,
93     -0.89477462, 1.67204106,  -0.53235275
94 ]
95
96 golden_outputs = [
97     0.014899,    -0.0517661, -0.143725, -0.00271883,
98     0.014899,    -0.0517661, -0.143725, -0.00271883,
99
100     0.068281,    -0.162217,  -0.152268, 0.00323521,
101     0.068281,    -0.162217,  -0.152268, 0.00323521,
102
103     -0.0317821,  -0.0333089, 0.0609602, 0.0333759,
104     -0.0317821,  -0.0333089, 0.0609602, 0.0333759,
105
106     -0.00623099, -0.077701,  -0.391193, -0.0136691,
107     -0.00623099, -0.077701,  -0.391193, -0.0136691,
108
109     0.201551,    -0.164607,  -0.179462, -0.0592739,
110     0.201551,    -0.164607,  -0.179462, -0.0592739,
111
112     0.0886511,   -0.0875401, -0.269283, 0.0281379,
113     0.0886511,   -0.0875401, -0.269283, 0.0281379,
114
115     -0.201174,   -0.586145,  -0.628624, -0.0330412,
116     -0.201174,   -0.586145,  -0.628624, -0.0330412,
117
118     -0.0839096,  -0.299329,  0.108746,  0.109808,
119     -0.0839096,  -0.299329,  0.108746,  0.109808,
120
121     0.419114,    -0.237824,  -0.422627, 0.175115,
122     0.419114,    -0.237824,  -0.422627, 0.175115,
123
124     0.36726,     -0.522303,  -0.456502, -0.175475,
125     0.36726,     -0.522303,  -0.456502, -0.175475
126 ]
127
128 output0 = {state_out: [0 for _ in range(batches * memory_size * features)],
129            output: []}
130
131 # TODO: enable more data points after fixing the reference issue
132 for i in range(1):
133   batch_start = i * input_size * batches
134   batch_end = batch_start + input_size * batches
135   input0[input] = test_inputs[batch_start:batch_end]
136   golden_start = i * units * batches
137   golden_end = golden_start + units * batches
138   output0[output] = golden_outputs[golden_start:golden_end]
139   Example((input0, output0))