ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Rsqrt.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
18#include "PALRsqrt.h"
19
20using namespace onert_micro;
21using namespace onert_micro::execute;
22
23// NOTE: doesnt currently support dynamic shapes
24namespace onert_micro
25{
26namespace execute
27{
28
30{
31 const circle::Tensor *input = nullptr;
32 const circle::Tensor *output = nullptr;
33
34 uint8_t *input_data = nullptr;
35 uint8_t *output_data = nullptr;
36
37 OMStatus status = SISOHeader(execute_args, &input, &output, &input_data, &output_data);
38 if (status != Ok)
39 return status;
40
41 switch (input->type())
42 {
43#ifndef DIS_FLOAT
44 case circle::TensorType_FLOAT32:
45 {
46 status = pal::Rsqrt(core::OMRuntimeShape(input), reinterpret_cast<const float *>(input_data),
47 core::OMRuntimeShape(output), reinterpret_cast<float *>(output_data));
48 }
49 break;
50#endif // DIS_FLOAT
51#ifndef DIS_QUANT
52 case circle::TensorType_INT8:
53 {
54 // TODO support CWQ
56 (*input->quantization()->scale())[0],
57 static_cast<int32_t>((*input->quantization()->zero_point())[0])};
59 (*output->quantization()->scale())[0],
60 static_cast<int32_t>((*output->quantization()->zero_point())[0])};
61
62 status = pal::QuantizedRsqrt<int8_t>(
63 core::OMRuntimeShape(input), in_qparams, reinterpret_cast<const int8_t *>(input_data),
64 core::OMRuntimeShape(output), out_qparams, reinterpret_cast<int8_t *>(output_data));
65 }
66 break;
67#endif
68 default:
69 {
70 status = UnsupportedType;
71 assert(false && "Unsupported type.");
72 }
73 }
74 return status;
75}
76
77} // namespace execute
78} // namespace onert_micro
OMStatus Rsqrt(const core::OMRuntimeShape &input_shape, const T *input_data, const core::OMRuntimeShape &output_shape, T *output_data)
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_CircleRsqrt(const OMExecuteArgs &execute_args)
Definition Rsqrt.cpp:29
@ UnsupportedType
Definition OMStatus.h:26