2 # Copyright (C) 2018 The Android Open Source Project
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 def test(input0, output0, axes, keep_dims, input_data, output_data):
18 model = Model().Operation("REDUCE_MAX", input0, axes, keep_dims).To(output0)
19 quant8 = DataTypeConverter().Identify({
20 input0: ["TENSOR_QUANT8_ASYMM", 0.5, 127],
21 output0: ["TENSOR_QUANT8_ASYMM", 0.5, 127],
26 }, model=model).AddVariations("relaxed", "float16", quant8)
29 input0=Input("input0", "TENSOR_FLOAT32", "{3, 2}"),
35 output0=Output("output0", "TENSOR_FLOAT32", "{3}"),
36 output_data=[-1, 4, 5],
39 # Tests below were adapted from tensorflow/lite/kernels/reduce_test.cc
42 input0=Input("input0", "TENSOR_FLOAT32", "{1}"),
46 output0=Output("output0", "TENSOR_FLOAT32", "{1}"),
51 input0=Input("input0", "TENSOR_FLOAT32", "{4, 3, 2}"),
52 input_data=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
53 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6,
54 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4],
57 output0=Output("output0", "TENSOR_FLOAT32", "{2}"),
58 output_data=[2.3, 2.4],
62 input0=Input("input0", "TENSOR_FLOAT32", "{4, 3, 2}"),
63 input_data=[0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
64 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6,
65 1.7, 1.8, 1.9, 2.0, 2.1, 2.2, 2.3, 2.4],
68 output0=Output("output0", "TENSOR_FLOAT32", "{1, 3, 1}"),
69 output_data=[2.0, 2.2, 2.4],