ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Softmax.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 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 "OMStatus.h"
18
19#include "core/OMUtils.h"
20
22
24#include "import/OMUtils.h"
25
26using namespace onert_micro;
27using namespace onert_micro::core;
28
29namespace
30{
31
32constexpr uint32_t inputTensorIdx = 0;
33constexpr uint32_t outputTensorIdx = 0;
34
35} // namespace
36
37OMStatus onert_micro::import::configure_kernel_CircleSoftmax(const OMConfigureArgs &config_args)
38{
39 const circle::Tensor *input;
40 const circle::Tensor *output;
41
42 SISOHeader(config_args, &input, &output);
43
44 OMStatus status;
45 status = utils::checkCondition(input->type() == output->type());
46 if (status != Ok)
47 return status;
48
49 OMRuntimeShape input_shape(input);
51
52 status = utils::checkCondition(input_shape.dimensionsCount() == output_shape.dimensionsCount());
53 if (status != Ok)
54 return status;
55
56 status = utils::checkCondition(input_shape.dimensionsCount() >= 1);
57 if (status != Ok)
58 return status;
59
60 if (input->type() != circle::TensorType_INT8 and input->type() != circle::TensorType_INT16 and
61 input->type() != circle::TensorType_UINT8)
62 return status;
63
64 // Check quantized version
65 if (input->quantization() == nullptr or output->quantization() == nullptr)
66 return NoQuantization;
67
68 if (output->quantization()->scale() == nullptr or output->quantization()->scale()->size() != 1)
69 return NoQuantization;
70
71 if (input->quantization()->scale() == nullptr or input->quantization()->scale()->size() != 1)
72 return NoQuantization;
73
74 if (output->quantization()->zero_point() == nullptr or
75 output->quantization()->zero_point()->size() != 1)
76 return NoQuantization;
77
78 if (input->quantization()->zero_point() == nullptr or
79 input->quantization()->zero_point()->size() != 1)
80 return NoQuantization;
81
82 return status;
83}
int32_t dimensionsCount() const
Definition Tensor.h:106
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
OMStatus SISOHeader(const OMExecuteArgs &execute_args, const circle::Tensor **input, const circle::Tensor **output, uint8_t **input_data, uint8_t **output_data)
Definition OMUtils.cpp:159
@ NoQuantization
Definition OMStatus.h:33