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 "GenModelTest.h"
19 struct DepthToSpaceVariationParam
22 circle::TensorType type = circle::TensorType::TensorType_FLOAT32;
24 int64_t zero_point = 0;
27 class DepthToSpaceVariation : public GenModelTest,
28 public ::testing::WithParamInterface<DepthToSpaceVariationParam>
32 INSTANTIATE_TEST_CASE_P(
33 GenModelTest, DepthToSpaceVariation,
36 DepthToSpaceVariationParam{
37 uniformTCD<float>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6, 3, 4, 7, 8}})},
39 DepthToSpaceVariationParam{
40 uniformTCD<int32_t>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6, 3, 4, 7, 8}}),
41 circle::TensorType::TensorType_INT32},
43 DepthToSpaceVariationParam{
44 uniformTCD<int64_t>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6, 3, 4, 7, 8}}),
45 circle::TensorType::TensorType_INT64},
47 DepthToSpaceVariationParam{
48 uniformTCD<uint8_t>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6, 3, 4, 7, 8}}),
49 circle::TensorType::TensorType_UINT8, 1.0f, -2},
51 DepthToSpaceVariationParam{
52 uniformTCD<int8_t>({{1, 2, 3, 4, 5, 6, 7, 8}}, {{1, 2, 5, 6, 3, 4, 7, 8}}),
53 circle::TensorType::TensorType_INT8, 1.0f, -2}));
55 // Input shape: {1, 1, 2, 4}
57 // Output shape: {1, 2, 4, 1}
58 TEST_P(DepthToSpaceVariation, Test)
60 auto ¶m = GetParam();
63 int in = cgen.addTensor({{1, 1, 2, 4}, param.type}, param.scale, param.zero_point);
64 int out = cgen.addTensor({{1, 2, 4, 1}, param.type}, param.scale, param.zero_point);
65 cgen.addOperatorDepthToSpace({{in}, {out}}, 2);
66 cgen.setInputsAndOutputs({in}, {out});
68 _context = std::make_unique<GenModelTestContext>(cgen.finish());
69 _context->addTestCase(param.tcd);
70 _context->setBackends({"acl_cl", "acl_neon", "cpu"});
75 TEST_F(GenModelTest, neg_OneOp_DepthToSpace_Blocksize)
78 circle::TensorType data_type = circle::TensorType::TensorType_FLOAT32;
79 int in = cgen.addTensor({{1, 1, 2, 4}, data_type});
80 int out = cgen.addTensor({{1, 2, 4, 1}, data_type});
81 cgen.addOperatorDepthToSpace({{in}, {out}}, -2);
82 cgen.setInputsAndOutputs({in}, {out});
84 _context = std::make_unique<GenModelTestContext>(cgen.finish());
85 _context->expectFailModelLoad();