Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / compiler / luci-interpreter / src / kernels / Logistic.test.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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 #include "kernels/Logistic.h"
18 #include "kernels/TestUtils.h"
19
20 namespace luci_interpreter
21 {
22 namespace kernels
23 {
24 namespace
25 {
26
27 using namespace testing;
28
29 TEST(LogisticTest, Float)
30 {
31   Shape input_shape{1, 2, 4, 1};
32   std::vector<float> input_data{
33       0, -6, 2,  4, //
34       3, -2, 10, 1, //
35   };
36   Tensor input_tensor = makeInputTensor<DataType::FLOAT32>(input_shape, input_data);
37   Tensor output_tensor = makeOutputTensor(DataType::FLOAT32);
38
39   Logistic kernel(&input_tensor, &output_tensor);
40   kernel.configure();
41   kernel.execute();
42
43   std::vector<float> ref_output_data{
44       0.5,      0.002473, 0.880797, 0.982014, //
45       0.952574, 0.119203, 0.999955, 0.731059, //
46   };
47   EXPECT_THAT(extractTensorData<float>(output_tensor),
48               ElementsAreArray(ArrayFloatNear(ref_output_data)));
49   // TODO make a Shape checking of output_tensor.
50 }
51
52 // TODO Uint8
53 // Need to Implement GetDequantizedOutput Function.
54
55 } // namespace
56 } // namespace kernels
57 } // namespace luci_interpreter