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