ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Minimum.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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#include "Builders.h"
18#include "kernels/Utils.h"
19
20#include "kernels/BinaryOpCommon.h"
21
22#include "PALMinimum.h"
23
24namespace luci_interpreter
25{
26
27void configure_kernel_CircleMinimum(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
28{
29 kernels::TISOKernel kernel(cur_op, runtime_graph);
30
32}
33
34void execute_kernel_CircleMinimum(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
35{
36 kernels::TISOKernel kernel(cur_op, runtime_graph);
38 kernels::getTensorRuntimeShape(kernel.input1(), runtime_graph);
40 kernels::getTensorRuntimeShape(kernel.input2(), runtime_graph);
42 kernels::getTensorRuntimeShape(kernel.output(), runtime_graph);
43
44 const uint8_t *input_data1 = runtime_graph->getDataByTensor(kernel.input1());
45 const uint8_t *input_data2 = runtime_graph->getDataByTensor(kernel.input2());
46 uint8_t *output_data = runtime_graph->getDataByTensor(kernel.output());
47
48 assert(input_data1 != nullptr);
49 assert(input_data2 != nullptr);
50 assert(output_data != nullptr);
51
52 switch (Tensor::element_type(kernel.input1()))
53 {
54#ifndef DIS_FLOAT
55 case DataType::FLOAT32:
56 {
57 // check that input and output dimensions are equal
58 if (kernels::areShapesEqual(input_shape1, input_shape2))
59 {
60 const int flat_size = input_shape1.flatSize();
61 luci_interpreter_pal::Minimum(flat_size, kernels::getTensorData<float>(input_data1),
62 kernels::getTensorData<float>(input_data2),
63 kernels::getTensorData<float>(output_data));
64 }
65 else
66 {
67 luci_interpreter_pal::BroadcastMinimum4DSlow<float>(
68 input_shape1, kernels::getTensorData<float>(input_data1), input_shape2,
69 kernels::getTensorData<float>(input_data2), output_shape,
70 kernels::getTensorData<float>(output_data));
71 }
72 }
73 break;
74#endif // DIS_FLOAT
75 default:
76 assert(false && "Unsupported type.");
77 }
78}
79
80} // namespace luci_interpreter
uint8_t * getDataByTensor(const circle::Tensor *raw_tensor)
const circle::Tensor * output() const
Definition TISOKernel.h:62
const circle::Tensor * input2() const
Definition TISOKernel.h:61
const circle::Tensor * input1() const
Definition TISOKernel.h:60
const luci_interpreter::RuntimeShape output_shape
bool areShapesEqual(const luci_interpreter::RuntimeShape &input_shape1, const luci_interpreter::RuntimeShape &input_shape2)
Definition Utils.cpp:89
void CheckBinaryOpDataTypesEqual(const kernels::TISOKernel &kernel)
luci_interpreter::RuntimeShape getTensorRuntimeShape(const circle::Tensor *circle_tensor, BaseRuntimeGraph *runtime_graph)
Definition Utils.cpp:29
void Minimum(const int flat_size, const float *input1_data, const float *input2_data, float *output_data)
void configure_kernel_CircleMinimum(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition Minimum.cpp:27
void execute_kernel_CircleMinimum(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
Definition Minimum.cpp:34