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_PROD", input0, axes, keep_dims).To(output0)
22 }, model=model).AddVariations("relaxed", "float16")
25 input0=Input("input0", "TENSOR_FLOAT32", "{3, 2}"),
31 output0=Output("output0", "TENSOR_FLOAT32", "{3}"),
32 output_data=[-1 * -2, 3 * 4, 5 * -6],
35 # Tests below were adapted from tensorflow/lite/kernels/reduce_test.cc
38 input0=Input("input0", "TENSOR_FLOAT32", "{1}"),
42 output0=Output("output0", "TENSOR_FLOAT32", "{1}"),
47 input0=Input("input0", "TENSOR_FLOAT32", "{4, 3, 2}"),
48 input_data=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
49 9.0, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60,
50 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40],
53 output0=Output("output0", "TENSOR_FLOAT32", "{2}"),
54 output_data=[3.16234143225e+4, 1.9619905536e+4],
58 input0=Input("input0", "TENSOR_FLOAT32", "{4, 3, 2}"),
59 input_data=[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0,
60 9.0, 1.00, 1.10, 1.20, 1.30, 1.40, 1.50, 1.60,
61 1.70, 1.80, 1.90, 2.00, 2.10, 2.20, 2.30, 2.40],
64 output0=Output("output0", "TENSOR_FLOAT32", "{1, 3, 1}"),
65 output_data=[7.74592e+2, 1.197504e+3, 6.6889152e+2],