2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "kernels/LeakyRelu.h"
18 #include "kernels/TestUtils.h"
20 namespace luci_interpreter
27 using namespace testing;
30 void Check(std::initializer_list<int32_t> input_shape, std::initializer_list<int32_t> output_shape,
31 std::initializer_list<T> input_data, std::initializer_list<T> output_data, float alpha,
32 DataType element_type)
34 Tensor input_tensor{element_type, input_shape, {}, ""};
35 input_tensor.writeData(input_data.begin(), input_data.size() * sizeof(T));
37 Tensor output_tensor = makeOutputTensor(element_type);
39 LeakyReluParams params{};
42 LeakyRelu kernel(&input_tensor, &output_tensor, params);
48 EXPECT_THAT(extractTensorData<T>(output_tensor), ::testing::ElementsAreArray(output_data));
51 TEST(LeakReluTest, FloatSimple)
53 Check<float>(/*input_shape=*/{2, 3}, /*output_shape=*/{2, 3}, /*input_data=*/
55 0.0f, 1.0f, 3.0f, // Row 1
56 1.0f, -1.0f, -2.0f, // Row 2
60 0.0f, 1.0f, 3.0f, // Row 1
61 1.0f, -0.5f, -1.0f, // Row 2
63 /*alpha=*/0.5f, getElementType<float>());
69 // Implement GetDequantizedOutput Function.
70 // Create Test for Uint8 Case
73 } // namespace kernels
74 } // namespace luci_interpreter