Home | History | Annotate | Download | only in V1_2
      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 
     17 # Derived from tensorflow/lite/kernels/activations_test.cc
     18 
     19 def test(input0, output0, input_data, beta, axis, output_data):
     20   model = Model().Operation("LOG_SOFTMAX", input0, beta, axis).To(output0)
     21   Example({
     22       input0: input_data,
     23       output0: output_data,
     24   }, model=model).AddVariations("relaxed", "float16")
     25 
     26 test(
     27     input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 1, 2, 4}"),
     28     output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 1, 2, 4}"),
     29     input_data=[0, -6, 2, 4,
     30                 3, -2, 10, 1],
     31     beta=1.0,
     32     axis=4,
     33     output_data=[-4.14297, -10.14297, -2.14297, -.142971,
     34                  -7.00104, -12.00104, -.00104087, -9.00104],
     35 )
     36 
     37 test(
     38     input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 1, 4, 2}"),
     39     output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 1, 4, 2}"),
     40     input_data=[0, -6,
     41                 2, 4,
     42                 3, -2,
     43                 10, 1],
     44     beta=1.0,
     45     axis=-1,
     46     output_data=[-.00247565, -6.00247,
     47                  -2.12692, -.126928,
     48                  -.00671534, -5.00671,
     49                  -.000123374, -9.00012],
     50 )
     51 
     52 test(
     53     input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 2, 4, 1}"),
     54     output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 2, 4, 1}"),
     55     input_data=[0, 2, 3, 10,
     56                 -6, 4, -2, 1],
     57     beta=1.0,
     58     axis=-3,
     59     output_data=[-.00247565, -2.12692, -.00671534, -.000123374,
     60                  -6.00247, -.126928, -5.00671, -9.00012],
     61 )
     62 
     63 test(
     64     input0=Input("input0", "TENSOR_FLOAT32", "{1, 1, 1, 2, 4}"),
     65     output0=Output("output0", "TENSOR_FLOAT32", "{1, 1, 1, 2, 4}"),
     66     input_data=[0, -.6, .2, .4,
     67                 .3, -.2, 1, .1],
     68     beta=10.0,
     69     axis=4,
     70     output_data=[-4.14297, -10.14297, -2.14297, -.142971,
     71                  -7.00104, -12.00104, -.00104087, -9.00104],
     72 )
     73