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
37namespace onert_micro
38{
39namespace import
40{
41
43{
44 const circle::Tensor *input;
45 const circle::Tensor *output;
46
47 SISOHeader(config_args, &input, &output);
48
49 OMStatus status;
50 status = utils::checkCondition(input->type() == output->type());
51 if (status != Ok)
52 return status;
53
54 OMRuntimeShape input_shape(input);
56
57 status = utils::checkCondition(input_shape.dimensionsCount() == output_shape.dimensionsCount());
58 if (status != Ok)
59 return status;
60
61 status = utils::checkCondition(input_shape.dimensionsCount() >= 1);
62 if (status != Ok)
63 return status;
64
65 if (input->type() != circle::TensorType_INT8 and input->type() != circle::TensorType_INT16 and
66 input->type() != circle::TensorType_UINT8)
67 return status;
68
69 // Check quantized version
70 if (input->quantization() == nullptr or output->quantization() == nullptr)
71 return NoQuantization;
72
73 if (output->quantization()->scale() == nullptr or output->quantization()->scale()->size() != 1)
74 return NoQuantization;
75
76 if (input->quantization()->scale() == nullptr or input->quantization()->scale()->size() != 1)
77 return NoQuantization;
78
79 if (output->quantization()->zero_point() == nullptr or
80 output->quantization()->zero_point()->size() != 1)
81 return NoQuantization;
82
83 if (input->quantization()->zero_point() == nullptr or
84 input->quantization()->zero_point()->size() != 1)
85 return NoQuantization;
86
87 return status;
88}
89
90} // namespace import
91} // namespace onert_micro
int32_t dimensionsCount() const
Definition Tensor.h:106
size_t dimensionsCount() const noexcept
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
OMStatus configure_kernel_CircleSoftmax(const OMConfigureArgs &config_args)
Definition Softmax.cpp:42
OMStatus SISOHeader(const OMConfigureArgs &execute_args, const circle::Tensor **input, const circle::Tensor **output)
Definition OMUtils.cpp:23
@ NoQuantization
Definition OMStatus.h:33