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 TEST_F(GenModelTest, OneOp_Pad)
22 int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
23 std::vector<int32_t> padding_data{0, 0, 1, 1, 1, 1, 0, 0};
24 uint32_t padding_buf = cgen.addBuffer(padding_data);
25 int padding = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_INT32, padding_buf});
26 int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
28 cgen.addOperatorPad({{in, padding}, {out}});
29 cgen.setInputsAndOutputs({in}, {out});
30 _context = std::make_unique<GenModelTestContext>(cgen.finish());
31 _context->addTestCase({{{1, 2, 3, 4}}, {{0, 0, 0, 0, 0, 1, 2, 0, 0, 3, 4, 0, 0, 0, 0, 0}}});
32 _context->setBackends({"acl_cl", "acl_neon", "cpu"});
37 TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadRank)
40 int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
41 std::vector<int32_t> padding_data{1, 1, 1, 1};
42 uint32_t padding_buf = cgen.addBuffer(padding_data);
43 int padding = cgen.addTensor({{4}, circle::TensorType::TensorType_INT32, padding_buf});
44 int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
46 cgen.addOperatorPad({{in, padding}, {out}});
47 cgen.setInputsAndOutputs({in}, {out});
49 _context = std::make_unique<GenModelTestContext>(cgen.finish());
50 _context->setBackends({"acl_cl", "acl_neon", "cpu"});
51 _context->setCompileFail();
56 TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadDim0)
59 int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
60 std::vector<int32_t> padding_data{1, 1, 1, 1};
61 uint32_t padding_buf = cgen.addBuffer(padding_data);
62 int padding = cgen.addTensor({{2, 2}, circle::TensorType::TensorType_INT32, padding_buf});
63 int out = cgen.addTensor({{1, 4, 4, 1}, circle::TensorType::TensorType_FLOAT32});
65 cgen.addOperatorPad({{in, padding}, {out}});
66 cgen.setInputsAndOutputs({in}, {out});
68 _context = std::make_unique<GenModelTestContext>(cgen.finish());
69 _context->setBackends({"acl_cl", "acl_neon", "cpu"});
70 _context->setCompileFail();
75 TEST_F(GenModelTest, neg_OneOp_Pad_InvalidPadDim1)
78 int in = cgen.addTensor({{1, 1, 1, 1}, circle::TensorType::TensorType_FLOAT32});
79 std::vector<int32_t> padding_data{1, 1, 1, 1};
80 uint32_t padding_buf = cgen.addBuffer(padding_data);
81 int padding = cgen.addTensor({{4, 1}, circle::TensorType::TensorType_INT32, padding_buf});
82 int out = cgen.addTensor({{2, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
84 cgen.addOperatorPad({{in, padding}, {out}});
85 cgen.setInputsAndOutputs({in}, {out});
87 _context = std::make_unique<GenModelTestContext>(cgen.finish());
88 _context->setBackends({"acl_cl", "acl_neon", "cpu"});
89 _context->setCompileFail();