ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PALAbs.h
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#ifndef ONERT_MICRO_EXECUTE_PAL_ABS_COMMON_H
18#define ONERT_MICRO_EXECUTE_PAL_ABS_COMMON_H
19
20#include "OMStatus.h"
21#include "core/OMRuntimeShape.h"
22
23#include <cmath>
24
25namespace onert_micro
26{
27namespace execute
28{
29namespace pal
30{
31
32template <typename T>
33inline OMStatus Abs(const core::OMRuntimeShape &shape, const T *input_data, T *output_data)
34{
35 const uint32_t flat_size = shape.flatSize();
36
37 if (flat_size == -1)
38 return UnknownError;
39
40 assert(input_data != nullptr);
41 assert(output_data != nullptr);
42
43 for (uint32_t i = 0; i < flat_size; ++i)
44 {
45 output_data[i] = std::abs(input_data[i]);
46 }
47
48 return Ok;
49}
50
51} // namespace pal
52} // namespace execute
53} // namespace onert_micro
54
55#endif // ONERT_MICRO_EXECUTE_PAL_ABS_COMMON_H
OMStatus Abs(const core::OMRuntimeShape &shape, const T *input_data, T *output_data)
Definition PALAbs.h:33