ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Logistic.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
23
24#include "execute/OMUtils.h"
25
26#include "PALLogistic.h"
27
28using namespace onert_micro;
29using namespace onert_micro::execute;
30
31namespace
32{
33
34constexpr uint32_t inputTensorIdx = 0;
35constexpr uint32_t outputTensorIdx = 0;
36
37} // namespace
38
39// NOTE: doesnt currently support dynamic shapes
40namespace onert_micro
41{
42namespace execute
43{
44
46{
47 const circle::Tensor *input = nullptr;
48 const circle::Tensor *output = nullptr;
49
50 uint8_t *input_data = nullptr;
51 uint8_t *output_data = nullptr;
52
53 SISOHeader(execute_args, &input, &output, &input_data, &output_data);
54
55 OMStatus status;
56
57 switch (input->type())
58 {
59#ifndef DIS_FLOAT
60 case circle::TensorType_FLOAT32:
61 {
62 status = pal::Logistic(core::OMRuntimeShape(input).flatSize(),
63 core::utils::castInputData<float>(input_data),
64 core::utils::castOutputData<float>(output_data));
65 }
66 break;
67#endif // DIS_FLOAT
68#ifndef DIS_QUANT
69 case circle::TensorType_INT8:
70 {
71 assert(input->quantization() != nullptr);
72 assert(input->quantization()->scale() != nullptr);
73 assert(input->quantization()->scale()->size() == 1);
74 assert(input->quantization()->zero_point() != nullptr);
75 assert(input->quantization()->zero_point()->size() == 1);
76
77 assert(output->quantization() != nullptr);
78 assert(output->quantization()->scale() != nullptr);
79 assert(output->quantization()->scale()->size() == 1);
80 assert(output->quantization()->zero_point() != nullptr);
81 assert(output->quantization()->zero_point()->size() == 1);
82
83 auto input_scale = *input->quantization()->scale()->begin();
84 auto input_zero_point = *input->quantization()->zero_point()->begin();
85 auto output_scale = *input->quantization()->scale()->begin();
86 auto output_zero_point = *input->quantization()->zero_point()->begin();
87
88 status = pal::Logistic(core::OMRuntimeShape(input).flatSize(),
89 core::utils::castInputData<int8_t>(input_data), input_scale,
90 input_zero_point, core::utils::castOutputData<int8_t>(output_data),
91 output_scale, output_zero_point);
92 }
93 break;
94#endif // DIS_QUANT
95 default:
96 {
97 status = UnsupportedType;
98 assert(false && "Unsupported type.");
99 }
100 }
101
102 return status;
103}
104
105} // namespace execute
106} // namespace onert_micro
constexpr uint32_t outputTensorIdx
OMStatus Logistic(const int flat_size, const float *input_data, float *output_data)
Definition PALLogistic.h:32
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
OMStatus execute_kernel_CircleLogistic(const OMExecuteArgs &execute_args)
Definition Logistic.cpp:45
@ UnsupportedType
Definition OMStatus.h:26