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/Squeeze.h"
18 #include "kernels/TestUtils.h"
19 #include "luci_interpreter/TestMemoryManager.h"
21 namespace luci_interpreter
28 using namespace testing;
31 void Check(std::initializer_list<int32_t> input_shape, std::initializer_list<int32_t> output_shape,
32 std::initializer_list<T> input_data, std::initializer_list<T> output_data,
33 std::initializer_list<int32_t> squeeze_dims)
35 std::unique_ptr<IMemoryManager> memory_manager = std::make_unique<TestMemoryManager>();
37 constexpr DataType element_type = getElementType<T>();
39 makeInputTensor<element_type>(input_shape, input_data, memory_manager.get());
40 Tensor output_tensor = makeOutputTensor(element_type);
42 SqueezeParams params{};
43 params.squeeze_dims = squeeze_dims;
45 Squeeze kernel(&input_tensor, &output_tensor, params);
47 memory_manager->allocate_memory(output_tensor);
50 EXPECT_THAT(extractTensorData<T>(output_tensor), ::testing::ElementsAreArray(output_data));
51 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape));
54 template <typename T> class SqueezeTest : public ::testing::Test
58 using DataTypes = ::testing::Types<float, uint8_t>;
59 TYPED_TEST_CASE(SqueezeTest, DataTypes);
61 TYPED_TEST(SqueezeTest, TotalTest)
64 /*input_shape=*/{1, 24, 1}, /*output_shape=*/{24},
65 /*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
66 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
67 /*output_data=*/{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
68 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
73 } // namespace kernels
74 } // namespace luci_interpreter