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_Neg_Float32)
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.addOperatorNeg({{in}, {out}});
25 cgen.setInputsAndOutputs({in}, {out});
27 _context = std::make_unique<GenModelTestContext>(cgen.finish());
28 _context->addTestCase(uniformTCD<float>({{1.1, -2.2, 3.3, -4.4}}, {{-1.1, 2.2, -3.3, 4.4}}));
29 _context->setBackends({"cpu"});
34 TEST_F(GenModelTest, OneOp_Neg_Int32)
37 int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
38 int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
39 cgen.addOperatorNeg({{in}, {out}});
40 cgen.setInputsAndOutputs({in}, {out});
42 _context = std::make_unique<GenModelTestContext>(cgen.finish());
43 _context->addTestCase(uniformTCD<int32_t>({{1, -2, 3, -4}}, {{-1, 2, -3, 4}}));
44 _context->setBackends({"cpu"});
49 TEST_F(GenModelTest, OneOp_Neg_Int64)
52 int in = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
53 int out = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
54 cgen.addOperatorNeg({{in}, {out}});
55 cgen.setInputsAndOutputs({in}, {out});
57 _context = std::make_unique<GenModelTestContext>(cgen.finish());
58 _context->addTestCase(uniformTCD<int64_t>({{1, -2, 3, -4}}, {{-1, 2, -3, 4}}));
59 _context->setBackends({"cpu"});
64 TEST_F(GenModelTest, neg_OneOp_Neg_Float32_TwoOperand)
67 int in1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
68 int in2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
69 int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
70 int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_FLOAT32});
71 cgen.addOperatorCos({{in1, in2}, {out1, out2}});
72 cgen.setInputsAndOutputs({in1, in2}, {out1, out2});
74 _context = std::make_unique<GenModelTestContext>(cgen.finish());
75 _context->setBackends({"cpu"});
76 _context->expectFailModelLoad();
81 TEST_F(GenModelTest, neg_OneOp_Neg_Int32_TwoOperand)
84 int in1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
85 int in2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
86 int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
87 int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT32});
88 cgen.addOperatorCos({{in1, in2}, {out1, out2}});
89 cgen.setInputsAndOutputs({in1, in2}, {out1, out2});
91 _context = std::make_unique<GenModelTestContext>(cgen.finish());
92 _context->setBackends({"cpu"});
93 _context->expectFailModelLoad();
98 TEST_F(GenModelTest, neg_OneOp_Neg_Int64_TwoOperand)
101 int in1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
102 int in2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
103 int out1 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
104 int out2 = cgen.addTensor({{1, 2, 2, 1}, circle::TensorType::TensorType_INT64});
105 cgen.addOperatorCos({{in1, in2}, {out1, out2}});
106 cgen.setInputsAndOutputs({in1, in2}, {out1, out2});
108 _context = std::make_unique<GenModelTestContext>(cgen.finish());
109 _context->setBackends({"cpu"});
110 _context->expectFailModelLoad();