ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Maximum.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 "PALMaximum.h"
23
24using namespace onert_micro;
25using namespace onert_micro::core;
26using namespace onert_micro::execute;
27
28OMStatus onert_micro::execute::execute_kernel_CircleMaximum(const OMExecuteArgs &execute_args)
29{
30
31 uint8_t *input_data1;
32 uint8_t *input_data2;
33 uint8_t *output_data;
34
35 core::OMRuntimeShape input_shape1;
36 core::OMRuntimeShape input_shape2;
38
39 circle::TensorType input1_type;
40
41 OMStatus status =
42 execute::readKernelDataTISO(execute_args, input_data1, input_data2, output_data, input_shape1,
43 input_shape2, output_shape, input1_type);
44
45 switch (input1_type)
46 {
47#ifndef DIS_FLOAT
48 case circle::TensorType_FLOAT32:
49 {
50 // check that input and output dimensions are equal
51 if (input_shape1 == input_shape2)
52 {
53 const int flat_size = input_shape1.flatSize();
54 status = pal::Maximum(flat_size, utils::castInputData<float>(input_data1),
55 utils::castInputData<float>(input_data2),
56 utils::castOutputData<float>(output_data));
57 }
58 else
59 {
60 status =
61 pal::BroadcastMaximum4DSlow(input_shape1, utils::castInputData<float>(input_data1),
62 input_shape2, utils::castInputData<float>(input_data2),
63 output_shape, utils::castOutputData<float>(output_data));
64 }
65 }
66 break;
67#endif // DIS_FLOAT
68 default:
69 assert(false && "Unsupported type.");
70 }
71
72 return status;
73}
const luci_interpreter::RuntimeShape output_shape
OMStatus Maximum(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)
OMStatus BroadcastMaximum4DSlow(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 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)