ONE - On-device Neural Engine
Loading...
Searching...
No Matches
AddN.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"
20
21#include "core/OMRuntimeShape.h"
22#include "PALAddN.h"
23
24using namespace onert_micro;
25using namespace onert_micro::execute;
26
27namespace
28{
29constexpr uint32_t outputTensorIdx = 0;
30} // namespace
31
32OMStatus onert_micro::execute::execute_kernel_CircleAddN(const OMExecuteArgs &execute_args)
33{
34 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
35 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
36 uint16_t op_index = execute_args.kernel_index;
37 const circle::Tensor *output;
38
39 uint8_t *output_data;
40
41 // Read kernel
42 execute::OMRuntimeKernel runtime_kernel;
43 runtime_kernel.readKernel(op_index, runtime_context);
44
45 output = runtime_kernel.outputs[outputTensorIdx];
46 assert(output != nullptr);
47
48 runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
50 assert(output_data != nullptr);
51
52 OMStatus status;
53
55 switch (output->type())
56 {
57#ifndef DIS_FLOAT
58 case circle::TensorType_FLOAT32:
59 {
60 status = onert_micro::execute::pal::AddN<float>(
61 output_shape.flatSize(), runtime_kernel.inputs_num,
62 reinterpret_cast<const float *const *>(runtime_kernel.inputs_data),
63 reinterpret_cast<float *>(output_data));
64 }
65 break;
66#endif // DIS_FLOAT
67 default:
68 {
69 status = UnsupportedType;
70 assert(false && "Unsupported type.");
71 }
72 }
73 return status;
74}
uint8_t * outputs_data[maxOutputSize]
OMStatus getDataFromStorage(uint16_t op_index, core::OMRuntimeStorage &storage, core::OMRuntimeContext &context)
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
@ UnsupportedType
Definition OMStatus.h:26
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage