ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PALFloorCommon.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_FLOOR_COMMON_H
18#define ONERT_MICRO_EXECUTE_PAL_FLOOR_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 Floor(const core::OMRuntimeShape &input_shape, const T *input_data,
34 const core::OMRuntimeShape &output_shape, T *output_data)
35{
36 const uint32_t flat_size = input_shape.flatSize();
37
38 if (flat_size == -1)
39 return UnknownError;
40
41 assert(input_data != nullptr);
42 assert(output_data != nullptr);
43
44 // check that input and output dimensions are equal
45 int N = input_shape.dimensionsCount();
46 assert(N == output_shape.dimensionsCount());
47
48 // check that sizes of all dimensions are equal
49 for (int i = 0; i < N; ++i)
50 {
51 assert(input_shape.dims(i) == output_shape.dims(i));
52 }
53
54 for (int i = 0; i < flat_size; i++)
55 {
56 output_data[i] = std::floor(input_data[i]);
57 }
58
59 return Ok;
60}
61
62} // namespace pal
63} // namespace execute
64} // namespace onert_micro
65
66#endif // ONERT_MICRO_EXECUTE_PAL_FLOOR_COMMON_H
int32_t dimensionsCount() const
Definition Tensor.h:106
int32_t dims(int i) const
Definition Tensor.h:108
const luci_interpreter::RuntimeShape output_shape
OMStatus Floor(const core::OMRuntimeShape &input_shape, const T *input_data, const core::OMRuntimeShape &output_shape, T *output_data)