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
40OMStatus onert_micro::execute::execute_kernel_CircleLogistic(const OMExecuteArgs &execute_args)
41{
42 const circle::Tensor *input = nullptr;
43 const circle::Tensor *output = nullptr;
44
45 uint8_t *input_data = nullptr;
46 uint8_t *output_data = nullptr;
47
48 SISOHeader(execute_args, &input, &output, &input_data, &output_data);
49
50 OMStatus status;
51
52 switch (input->type())
53 {
54#ifndef DIS_FLOAT
55 case circle::TensorType_FLOAT32:
56 {
57 status = pal::Logistic(core::OMRuntimeShape(input).flatSize(),
58 core::utils::castInputData<float>(input_data),
59 core::utils::castOutputData<float>(output_data));
60 }
61 break;
62#endif // DIS_FLOAT
63#ifndef DIS_QUANT
64 case circle::TensorType_INT8:
65 {
66 assert(input->quantization() != nullptr);
67 assert(input->quantization()->scale() != nullptr);
68 assert(input->quantization()->scale()->size() == 1);
69 assert(input->quantization()->zero_point() != nullptr);
70 assert(input->quantization()->zero_point()->size() == 1);
71
72 assert(output->quantization() != nullptr);
73 assert(output->quantization()->scale() != nullptr);
74 assert(output->quantization()->scale()->size() == 1);
75 assert(output->quantization()->zero_point() != nullptr);
76 assert(output->quantization()->zero_point()->size() == 1);
77
78 auto input_scale = *input->quantization()->scale()->begin();
79 auto input_zero_point = *input->quantization()->zero_point()->begin();
80 auto output_scale = *input->quantization()->scale()->begin();
81 auto output_zero_point = *input->quantization()->zero_point()->begin();
82
83 status = pal::Logistic(core::OMRuntimeShape(input).flatSize(),
84 core::utils::castInputData<int8_t>(input_data), input_scale,
85 input_zero_point, core::utils::castOutputData<int8_t>(output_data),
86 output_scale, output_zero_point);
87 }
88 break;
89#endif // DIS_QUANT
90 default:
91 {
92 status = UnsupportedType;
93 assert(false && "Unsupported type.");
94 }
95 }
96
97 return status;
98}
constexpr uint32_t outputTensorIdx
list input_data
Definition infer.py:29
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
@ UnsupportedType
Definition OMStatus.h:26