2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3 * Copyright 2019 The TensorFlow Authors. All Rights Reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "kernels/SpaceToDepth.h"
19 #include "kernels/TestUtils.h"
20 #include "luci_interpreter/TestMemoryManager.h"
22 namespace luci_interpreter
29 using namespace testing;
31 template <typename T> class SpaceToDepthTest : public ::testing::Test
35 using DataTypes = ::testing::Types<float, uint8_t>;
36 TYPED_TEST_SUITE(SpaceToDepthTest, DataTypes);
38 TYPED_TEST(SpaceToDepthTest, SimpleCase)
40 std::unique_ptr<IMemoryManager> memory_manager = std::make_unique<TestMemoryManager>();
42 constexpr DataType element_type = getElementType<TypeParam>();
43 std::vector<TypeParam> input_data{1, 5, 6, 7, 2, 3, 4, 8};
44 Shape input_shape{1, 2, 2, 2};
46 makeInputTensor<element_type>(input_shape, input_data, memory_manager.get());
47 std::vector<TypeParam> output_data{1, 5, 6, 7, 2, 3, 4, 8};
48 std::vector<int32_t> output_shape{1, 1, 1, 8};
49 Tensor output_tensor = makeOutputTensor(element_type);
51 SpaceToDepthParams params{};
52 params.block_size = 2;
54 SpaceToDepth kernel(&input_tensor, &output_tensor, params);
56 memory_manager->allocate_memory(output_tensor);
59 EXPECT_THAT(extractTensorData<TypeParam>(output_tensor),
60 ::testing::ElementsAreArray(output_data));
61 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape));
65 } // namespace kernels
66 } // namespace luci_interpreter