Imported Upstream version 1.12.0
[platform/core/ml/nnfw.git] / tests / nnfw_api / src / one_op_tests / ResizeNearestNeighbor.cc
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "GenModelTest.h"
18
19 TEST_F(GenModelTest, OneOp_ResizeNearestNeighbor)
20 {
21   CircleGen cgen;
22   int in = cgen.addTensor({{1, 2, 2, 2}, circle::TensorType::TensorType_FLOAT32});
23   std::vector<int32_t> size_data{3, 3};
24   uint32_t size_buf = cgen.addBuffer(size_data);
25   int size = cgen.addTensor({{2}, circle::TensorType::TensorType_INT32, size_buf});
26
27   int out = cgen.addTensor({{1, 3, 3, 2}, circle::TensorType::TensorType_FLOAT32});
28
29   cgen.addOperatorResizeNearestNeighbor({{in, size}, {out}});
30   cgen.setInputsAndOutputs({in}, {out});
31
32   _context = std::make_unique<GenModelTestContext>(cgen.finish());
33   _context->addTestCase(
34     uniformTCD<float>({{3, 4, 6, 10, 9, 10, 12, 16}},
35                       {{3, 4, 3, 4, 6, 10, 3, 4, 3, 4, 6, 10, 9, 10, 9, 10, 12, 16}}));
36   _context->setBackends({"acl_cl"});
37
38   SUCCEED();
39 }