Imported Upstream version 1.9.0
[platform/core/ml/nnfw.git] / tests / nnfw_api / src / one_op_tests / Cos.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_Cos)
20 {
21   CircleGen cgen;
22   int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
23   int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
24   cgen.addOperatorCos({{in}, {out}});
25   cgen.setInputsAndOutputs({in}, {out});
26
27   _context = std::make_unique<GenModelTestContext>(cgen.finish());
28   const float pi = 3.141592653589793;
29   _context->addTestCase({{{0, pi / 2, pi, 7}}, {{1, 0, -1, 0.75390225434}}});
30   _context->setBackends({"cpu"});
31
32   SUCCEED();
33 }
34
35 TEST_F(GenModelTest, neg_OneOp_Cos_TwoOperand)
36 {
37   CircleGen cgen;
38   int lhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
39   int rhs = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
40   int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
41   int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
42   cgen.addOperatorCos({{lhs, rhs}, {out1, out2}});
43   cgen.setInputsAndOutputs({lhs, rhs}, {out1, out2});
44
45   _context = std::make_unique<GenModelTestContext>(cgen.finish());
46   _context->setBackends({"cpu"});
47   _context->setCompileFail();
48
49   SUCCEED();
50 }