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 "core/OMUtils.h"
19#include "OMStatus.h"
21
22using namespace onert_micro;
23using namespace onert_micro::core;
24
25namespace
26{
27
28constexpr uint32_t input1TensorIdx = 0;
29constexpr uint32_t outputTensorIdx = 0;
30
31} // namespace
32
33namespace onert_micro
34{
35namespace import
36{
37
39{
40 OMRuntimeContext &runtime_context = config_args.runtime_context;
41 uint16_t op_index = config_args.kernel_index;
42
44
45 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
46 if (status != Ok)
47 return status;
48
49 const auto kInputsNum = runtime_kernel.inputs_num;
50
51 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
52 assert(output != nullptr);
53 const circle::Tensor *input1 = runtime_kernel.inputs[input1TensorIdx];
54 assert(input1 != nullptr);
55 const OMRuntimeShape input1_shape(input1);
56
57 for (int idx = 1; idx < kInputsNum; ++idx)
58 {
59 const circle::Tensor *input = runtime_kernel.inputs[idx];
60 assert(input != nullptr);
61 status = utils::checkCondition(input1->type() == input->type());
62 if (status != Ok)
63 return status;
64 }
65
66 status = utils::checkCondition(input1->type() == output->type());
67 if (status != Ok)
68 return status;
69
70 for (int idx = 1; idx < kInputsNum; ++idx)
71 {
72 const circle::Tensor *input = runtime_kernel.inputs[idx];
73 assert(input != nullptr);
74 const OMRuntimeShape input_shape(input);
75 status = utils::checkCondition(input_shape == input1_shape);
76 if (status != Ok)
77 return status;
78 }
79
80 status = utils::checkCondition(input1->type() != circle::TensorType_INT8 and
81 input1->type() != circle::TensorType_INT16);
82 if (status != Ok)
83 return status;
84
85 return status;
86}
87
88} // namespace import
89} // namespace onert_micro
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
constexpr uint32_t input1TensorIdx
constexpr uint32_t outputTensorIdx
OMStatus configure_kernel_CircleAddN(const OMConfigureArgs &config_args)
Definition AddN.cpp:38
core::OMRuntimeContext & runtime_context