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 OMStatus status = SISOHeader(execute_args, &input, &output, &input_data, &output_data);
38 if (status != OMStatus::Ok)
39 return status;
40
41 switch (input->type())
42 {
43#ifndef DIS_FLOAT
44 case circle::TensorType_FLOAT32:
45 {
46 status =
47 pal::Tanh<float>(core::OMRuntimeShape(input), reinterpret_cast<const float *>(input_data),
48 core::OMRuntimeShape(output), reinterpret_cast<float *>(output_data));
49 }
50 break;
51#endif // DIS_FLOAT
52#ifndef DIS_QUANT
53 case circle::TensorType_INT8:
54 {
55 // TODO support CWQ
57 (*input->quantization()->scale())[0],
58 static_cast<int32_t>((*input->quantization()->zero_point())[0])};
60 (*output->quantization()->scale())[0],
61 static_cast<int32_t>((*output->quantization()->zero_point())[0])};
62
63 status = pal::QuantizedTanh<int8_t>(
64 core::OMRuntimeShape(input), in_qparams, reinterpret_cast<const int8_t *>(input_data),
65 core::OMRuntimeShape(output), out_qparams, reinterpret_cast<int8_t *>(output_data));
66 }
67 break;
68#endif // DIS_QUANT
69 default:
70 {
71 status = UnsupportedType;
72 assert(false && "Unsupported type.");
73 }
74 }
75
76 return status;
77}
78
79} // namespace execute
80} // 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
@ UnsupportedType
Definition OMStatus.h:26