ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Tanh.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 "PALTanh.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 =
46 pal::Tanh<float>(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::QuantizedTanh<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#endif // DIS_QUANT
67 }
68
69 return status;
70}
71
72} // namespace execute
73} // namespace onert_micro
OMStatus execute_kernel_CircleTanh(const OMExecuteArgs &execute_args)
Definition Tanh.cpp:29
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