ONE - On-device Neural Engine
Loading...
Searching...
No Matches
FloorMod.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 "OMStatus.h"
21#include "core/OMUtils.h"
22#include "PALFloorMod.h"
23
24using namespace onert_micro;
25using namespace onert_micro::core;
26
27// NOTE: doesnt currently support dynamic shapes
28namespace onert_micro
29{
30namespace execute
31{
32
34{
35 uint8_t *input_data1;
36 uint8_t *input_data2;
37 uint8_t *output_data;
38
39 core::OMRuntimeShape input_shape1;
40 core::OMRuntimeShape input_shape2;
42
43 circle::TensorType input1_type;
44
45 OMStatus status =
46 execute::readKernelDataTISO(execute_args, input_data1, input_data2, output_data, input_shape1,
47 input_shape2, output_shape, input1_type);
48
49 switch (input1_type)
50 {
51#ifndef DIS_FLOAT
52 case circle::TensorType_FLOAT32:
53 {
54 // Check the denominator
55 for (int i = 0; i < input_shape2.flatSize(); ++i)
56 {
57 utils::checkCondition(core::utils::castInputData<float>(input_data2)[i] != 0);
58 }
59 // check that input and output dimensions are equal
60 if (input_shape1 == input_shape2)
61 {
62 const int flat_size = input_shape1.flatSize();
63 pal::FloorMod(flat_size, core::utils::castInputData<float>(input_data1),
64 core::utils::castInputData<float>(input_data2),
65 core::utils::castOutputData<float>(output_data));
66 }
67 else
68 {
69 pal::BroadcastFloorMod4DSlow(input_shape1, core::utils::castInputData<float>(input_data1),
70 input_shape2, core::utils::castInputData<float>(input_data2),
71 output_shape, core::utils::castOutputData<float>(output_data));
72 }
73 }
74 break;
75#endif // DIS_FLOAT
76 default:
77 assert(false && "Unsupported type.");
78 }
79
80 return status;
81}
82
83} // namespace execute
84} // namespace onert_micro
const luci_interpreter::RuntimeShape output_shape
void FloorMod(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)
void BroadcastFloorMod4DSlow(const core::OMRuntimeShape &input1_shape, const float *input1_data, const core::OMRuntimeShape &input2_shape, const float *input2_data, const core::OMRuntimeShape &output_shape, float *output_data)
OMStatus execute_kernel_CircleFloorMod(const OMExecuteArgs &execute_args)
Definition FloorMod.cpp:33
OMStatus readKernelDataTISO(const OMExecuteArgs &execute_args, uint8_t *&input_data1, uint8_t *&input_data2, uint8_t *&output_data, core::OMRuntimeShape &input1_shape_ref, core::OMRuntimeShape &input2_shape_ref, core::OMRuntimeShape &output_shape_ref, circle::TensorType &tensor_type)