1#
2# Copyright (C) 2019 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#
16def test(name, input_dims, value, output, input_dims_data, output_data):
17  model = Model().Operation("FILL", input_dims, value).To(output)
18  example = Example({
19      input_dims: input_dims_data,
20      output: output_data,
21  },
22                    model=model,
23                    name=name).AddVariations("float16", "int32")
24
25
26test(
27    name="1d",
28    input_dims=Input("input0", "TENSOR_INT32", "{1}"),
29    value=Float32Scalar("value", 3.0),
30    output=Output("output", "TENSOR_FLOAT32", "{5}"),
31    input_dims_data=[5],
32    output_data=[3.0] * 5,
33)
34
35test(
36    name="3d",
37    input_dims=Input("input0", "TENSOR_INT32", "{3}"),
38    value=Float32Scalar("value", 3.0),
39    output=Output("output", "TENSOR_FLOAT32", "{2, 3, 4}"),
40    input_dims_data=[2, 3, 4],
41    output_data=[3.0] * (2 * 3 * 4),
42)
43
44test(
45    name="5d",
46    input_dims=Input("input0", "TENSOR_INT32", "{5}"),
47    value=Float32Scalar("value", 3.0),
48    output=Output("output", "TENSOR_FLOAT32", "{1, 2, 3, 4, 5}"),
49    input_dims_data=[1, 2, 3, 4, 5],
50    output_data=[3.0] * (1 * 2 * 3 * 4 * 5),
51)
52