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"
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,
32 DataType element_type, std::vector<int32_t> squeeze_dims)
34 Tensor input_tensor{element_type, input_shape, {}, ""};
35 input_tensor.writeData(input_data.begin(), input_data.size() * sizeof(T));
36 Tensor output_tensor = makeOutputTensor(element_type);
38 SqueezeParams params{};
39 for (size_t i = 0; i < squeeze_dims.size(); i++)
41 params.squeeze_dims.push_back(squeeze_dims.at(i));
44 Squeeze kernel(&input_tensor, &output_tensor, params);
48 EXPECT_THAT(extractTensorData<T>(output_tensor), ::testing::ElementsAreArray(output_data));
49 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape));
52 template <typename T> class SqueezeTest : public ::testing::Test
56 using DataTypes = ::testing::Types<float, uint8_t>;
57 TYPED_TEST_CASE(SqueezeTest, DataTypes);
59 TYPED_TEST(SqueezeTest, TotalTest)
62 /*input_shape=*/{1, 24, 1}, /*output_shape=*/{24},
63 /*input_data=*/{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
64 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24},
65 /*output_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 getElementType<TypeParam>(), {-1, 0});
71 } // namespace kernels
72 } // namespace luci_interpreter