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 SISOHeader(execute_args, &input, &output, &input_data, &output_data);
38
39 OMStatus status;
40 switch (input->type())
41 {
42#ifndef DIS_FLOAT
43 case circle::TensorType_FLOAT32:
44 {
45 status = pal::Rsqrt(core::OMRuntimeShape(input), reinterpret_cast<const float *>(input_data),
46 core::OMRuntimeShape(output), reinterpret_cast<float *>(output_data));
47 }
48 break;
49#endif // DIS_FLOAT
50#ifndef DIS_QUANT
51 case circle::TensorType_INT8:
52 {
53 // TODO support CWQ
55 (*input->quantization()->scale())[0],
56 static_cast<int32_t>((*input->quantization()->zero_point())[0])};
58 (*output->quantization()->scale())[0],
59 static_cast<int32_t>((*output->quantization()->zero_point())[0])};
60
61 status = pal::QuantizedRsqrt<int8_t>(
62 core::OMRuntimeShape(input), in_qparams, reinterpret_cast<const int8_t *>(input_data),
63 core::OMRuntimeShape(output), out_qparams, reinterpret_cast<int8_t *>(output_data));
64 }
65#endif
66 }
67 return status;
68}
69
70} // namespace execute
71} // 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