Imported Upstream version 1.4.0
[platform/core/ml/nnfw.git] / tests / nnapi / specs / V1_2 / expand_dims.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 input0 = Input("input0", "TENSOR_FLOAT32", "{2, 2}")
18
19 output0 = Output("output", "TENSOR_FLOAT32", "{1, 2, 2}")
20 output1 = Output("output", "TENSOR_FLOAT32", "{2, 1, 2}")
21 output2 = Output("output", "TENSOR_FLOAT32", "{2, 2, 1}")
22 output3 = output2
23
24 model0 = Model().Operation("EXPAND_DIMS", input0, 0).To(output0)
25 model1 = Model().Operation("EXPAND_DIMS", input0, 1).To(output1)
26 model2 = Model().Operation("EXPAND_DIMS", input0, 2).To(output2)
27 model3 = Model().Operation("EXPAND_DIMS", input0, -1).To(output3)
28
29 data = [1.2, -3.4, 5.6, 7.8]
30
31 for model, output in [(model0, output0),
32                       (model1, output1),
33                       (model2, output2),
34                       (model3, output3)]:
35   quant8 = DataTypeConverter().Identify({
36       input0: ["TENSOR_QUANT8_ASYMM", 0.5, 127],
37       output: ["TENSOR_QUANT8_ASYMM", 0.5, 127],
38   })
39
40   int32 = DataTypeConverter().Identify({
41       input0: ["TENSOR_INT32"],
42       output: ["TENSOR_INT32"],
43   })
44
45   Example({
46       input0: data,
47       output: data,
48   }, model=model).AddVariations("relaxed", quant8, int32, "float16")