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/Floor.h"
18 #include "kernels/TestUtils.h"
19 #include "luci_interpreter/TestMemoryManager.h"
21 namespace luci_interpreter
28 using namespace testing;
30 class FloorTest : public ::testing::Test
33 void SetUp() override { _memory_manager = std::make_unique<TestMemoryManager>(); }
35 std::unique_ptr<IMemoryManager> _memory_manager;
38 TEST_F(FloorTest, SimpleFloat)
40 std::initializer_list<int32_t> input_shape{1, 2, 4, 1};
41 std::vector<float> input_data{
42 0.2, 8.6, 2.4, 4.3, // Row 1
43 3, 7.1, 10.5, -0.9, // Row 2
46 std::initializer_list<int32_t> ref_output_shape{1, 2, 4, 1};
47 std::vector<float> ref_output_data{
49 3, 7, 10, -1, // Row 2
53 makeInputTensor<DataType::FLOAT32>(input_shape, input_data, _memory_manager.get());
54 Tensor output_tensor = makeOutputTensor(DataType::FLOAT32);
56 Floor kernel(&input_tensor, &output_tensor);
58 _memory_manager->allocate_memory(output_tensor);
61 EXPECT_THAT(extractTensorData<float>(output_tensor), FloatArrayNear(ref_output_data));
62 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(ref_output_shape));
65 TEST_F(FloorTest, Input_Output_Type_NEG)
67 Tensor input_tensor = makeInputTensor<DataType::FLOAT32>({1}, {1.f}, _memory_manager.get());
68 Tensor output_tensor = makeOutputTensor(DataType::S32);
70 Floor kernel(&input_tensor, &output_tensor);
71 EXPECT_ANY_THROW(kernel.configure());
75 } // namespace kernels
76 } // namespace luci_interpreter