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
17def test(input0, output0, axes, keep_dims, input_data, output_data):
18  model = Model().Operation("REDUCE_ANY", input0, axes, keep_dims).To(output0)
19  Example({
20      input0: input_data,
21      output0: output_data,
22  }, model=model)
23
24# Tests below were adapted from tensorflow/lite/kernels/reduce_test.cc
25
26test(
27    input0=Input("input0", "TENSOR_BOOL8", "{1}"),
28    input_data=[False],
29    axes=[0],
30    keep_dims=True,
31    output0=Output("output0", "TENSOR_BOOL8", "{1}"),
32    output_data=[False],
33)
34
35test(
36    input0=Input("input0", "TENSOR_BOOL8", "{2, 3, 2}"),
37    input_data=[False, False, False, False, False, False,
38                False, True,  False, False, False, True],
39    axes=[1, 0, -3, -3],
40    keep_dims=False,
41    output0=Output("output0", "TENSOR_BOOL8", "{2}"),
42    output_data=[False, True],
43)
44
45test(
46    input0=Input("input0", "TENSOR_BOOL8", "{2, 3, 2}"),
47    input_data=[False, False, False, False, False, False,
48                False, True,  False, False, False, True],
49    axes=[0, 2],
50    keep_dims=True,
51    output0=Output("output0", "TENSOR_BOOL8", "{1, 3, 1}"),
52    output_data=[True, False, True],
53)
54