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