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
17input0 = Input("input0", "TENSOR_FLOAT32", "{2, 2}")
18
19output0 = Output("output", "TENSOR_FLOAT32", "{1, 2, 2}")
20output1 = Output("output", "TENSOR_FLOAT32", "{2, 1, 2}")
21output2 = Output("output", "TENSOR_FLOAT32", "{2, 2, 1}")
22output3 = output2
23
24model0 = Model().Operation("EXPAND_DIMS", input0, 0).To(output0)
25model1 = Model().Operation("EXPAND_DIMS", input0, 1).To(output1)
26model2 = Model().Operation("EXPAND_DIMS", input0, 2).To(output2)
27model3 = Model().Operation("EXPAND_DIMS", input0, -1).To(output3)
28
29data = [1.2, -3.4, 5.6, 7.8]
30
31for 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")
49