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_LogSoftmax)
21 // NOTE For tf lite the params are fixed as:
22 // beta = 1.0, axis = -1
25 int in = cgen.addTensor({{1, 1, 1, 4, 2}, circle::TensorType::TensorType_FLOAT32});
26 int out = cgen.addTensor({{1, 1, 1, 4, 2}, circle::TensorType::TensorType_FLOAT32});
27 cgen.addOperatorLogSoftmax({{in}, {out}});
28 cgen.setInputsAndOutputs({in}, {out});
30 _context = std::make_unique<GenModelTestContext>(cgen.finish());
31 _context->setBackends({"cpu"});
32 _context->addTestCase(uniformTCD<float>(
33 {{0, -6, 2, 4, 3, -2, 10, 1}},
34 {{-.00247565, -6.00247, -2.12692, -.126928, -.00671534, -5.00671, -.000123374, -9.00012}}));
39 TEST_F(GenModelTest, neg_OneOp_LogSoftmax_InvalidModel)
42 int out = cgen.addTensor({{4, 2}, circle::TensorType::TensorType_FLOAT32});
43 cgen.addOperatorLogSoftmax({{}, {out}}); // No input tensor
44 cgen.setInputsAndOutputs({}, {out});
46 _context = std::make_unique<GenModelTestContext>(cgen.finish());
47 _context->setBackends({"cpu"});
48 _context->expectFailModelLoad();