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
32namespace onert_micro
33{
34namespace execute
35{
36
38{
39 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
40 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
41 uint16_t op_index = execute_args.kernel_index;
42 const circle::Tensor *output;
43
44 uint8_t *output_data;
45
46 // Read kernel
47 execute::OMRuntimeKernel runtime_kernel;
48 runtime_kernel.readKernel(op_index, runtime_context);
49
50 output = runtime_kernel.outputs[outputTensorIdx];
51 assert(output != nullptr);
52
53 runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
54 output_data = runtime_kernel.outputs_data[outputTensorIdx];
55 assert(output_data != nullptr);
56
57 OMStatus status;
58
60 switch (output->type())
61 {
62#ifndef DIS_FLOAT
63 case circle::TensorType_FLOAT32:
64 {
65 status = onert_micro::execute::pal::AddN<float>(
66 output_shape.flatSize(), runtime_kernel.inputs_num,
67 reinterpret_cast<const float *const *>(runtime_kernel.inputs_data),
68 reinterpret_cast<float *>(output_data));
69 }
70 break;
71#endif // DIS_FLOAT
72 default:
73 {
74 status = UnsupportedType;
75 assert(false && "Unsupported type.");
76 }
77 }
78 return status;
79}
80
81} // namespace execute
82} // namespace onert_micro
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
OMStatus execute_kernel_CircleAddN(const OMExecuteArgs &execute_args)
Definition AddN.cpp:37
@ UnsupportedType
Definition OMStatus.h:26
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage