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/DepthToSpace.h"
18 #include "kernels/TestUtils.h"
20 namespace luci_interpreter
27 using namespace testing;
29 template <typename T> class DepthToSpaceTest : public ::testing::Test
33 using DataTypes = ::testing::Types<float, uint8_t>;
34 TYPED_TEST_CASE(DepthToSpaceTest, DataTypes);
36 TYPED_TEST(DepthToSpaceTest, SimpleCase)
38 std::vector<TypeParam> input_data{1, 2, 3, 4, 5, 6, 7, 8};
39 Shape input_shape{1, 1, 2, 4};
40 std::vector<TypeParam> output_data{1, 2, 5, 6, 3, 4, 7, 8};
41 std::vector<int32_t> output_shape{1, 2, 4, 1};
43 Tensor input_tensor = makeInputTensor<getElementType<TypeParam>()>(input_shape, input_data);
44 Tensor output_tensor = makeOutputTensor(getElementType<TypeParam>());
46 DepthToSpaceParams params{};
47 params.block_size = 2;
49 DepthToSpace kernel = DepthToSpace(&input_tensor, &output_tensor, params);
53 EXPECT_THAT(extractTensorData<TypeParam>(output_tensor),
54 ::testing::ElementsAreArray(output_data));
55 EXPECT_THAT(extractTensorShape(output_tensor), ::testing::ElementsAreArray(output_shape));
59 } // namespace kernels
60 } // namespace luci_interpreter