2 # Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 # Copyright (C) 2018 The Android Open Source Project
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Derived from tensorflow/lite/kernels/activations_test.cc
20 def test(input0, output0, input_data, beta, axis, output_data):
21 model = Model().Operation("LOG_SOFTMAX", input0, beta, axis).To(output0)
25 }, model=model).AddVariations("relaxed", "float16")
28 input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
29 output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
30 input_data=[0, -6, 2, 4,
34 output_data=[-4.14297, -10.14297, -2.14297, -.142971,
35 -7.00104, -12.00104, -.00104087, -9.00104],
39 input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 4, 2}"),
40 output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 4, 2}"),
47 output_data=[-.00247565, -6.00247,
50 -.000123374, -9.00012],
54 input0=Input("input0", "TENSOR_FLOAT32", "{1, 2, 4, 1}"),
55 output0=Output("output0", "TENSOR_FLOAT32", "{1, 2, 4, 1}"),
56 input_data=[0, 2, 3, 10,
60 output_data=[-.00247565, -2.12692, -.00671534, -.000123374,
61 -6.00247, -.126928, -5.00671, -9.00012],
65 input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
66 output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
67 input_data=[0, -.6, .2, .4,
71 output_data=[-4.14297, -10.14297, -2.14297, -.142971,
72 -7.00104, -12.00104, -.00104087, -9.00104],
75 def quant8_test(input0, output0, input_data, beta, axis, output_data):
76 model = Model().Operation("LOG_SOFTMAX", input0, beta, axis).To(output0)
77 quant8 = DataTypeConverter().Identify({
78 input0: ["TENSOR_QUANT8_ASYMM", 10 / 255.0],
79 output0: ["TENSOR_QUANT8_ASYMM", 16 / 256.0, 255],
85 }, model=model).AddVariations(quant8)
88 input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
89 output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 2, 4}"),
90 input_data=[0, 6, 2, 4,
94 output_data=[-6.145078, -.145078, -4.145078, -2.145078,
95 -7.001370, -8.001370, -.001370, -9.001370],