ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Concatenation.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
22#include "core/OMDataType.h"
23
24using namespace onert_micro;
25using namespace onert_micro::core;
26
28onert_micro::import::configure_kernel_CircleConcatenation(const OMConfigureArgs &config_args)
29{
30 OMRuntimeContext &runtime_context = config_args.runtime_context;
31 uint16_t op_index = config_args.kernel_index;
32
34
35 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
36 if (status != Ok)
37 return status;
38
39 const int num_inputs = runtime_kernel.inputs_num;
40
41 const auto *t0 = runtime_kernel.inputs[0];
42 const auto *output = runtime_kernel.outputs[0];
43
44 const auto *params = runtime_kernel.first_operator->builtin_options_as_ConcatenationOptions();
45
46 // TODO: Support concat with fused activation function
47 if (params->fused_activation_function() != circle::ActivationFunctionType_NONE)
48 return UnknownError;
49
50 OMRuntimeShape input_shape(t0);
51 int axis = params->axis();
52 if (axis < 0)
53 axis += input_shape.dimensionsCount();
54
55 if (axis < 0 or axis > input_shape.dimensionsCount())
57
58 for (int i = 1; i < num_inputs; ++i)
59 {
60 const auto *tensor = runtime_kernel.inputs[i];
61 if (tensor->type() != t0->type())
63 }
64
65 if (t0->type() != circle::TensorType_INT8 and t0->type() != circle::TensorType_INT16)
66 return Ok;
67
68#ifndef DIS_QUANT
69 // If input tensors are INT8 or INT16 type then quantization parameters of all input tensors and
70 // the output should be the same
71 for (int i = 0; i < num_inputs; ++i)
72 {
73 const auto *tensor = runtime_kernel.inputs[i];
74
75 if (tensor->quantization() == nullptr)
77
78 if (tensor->quantization()->scale()->size() != 1)
80
81 if (tensor->quantization()->zero_point()->size() != 1)
83
84 if (*tensor->quantization()->scale()->begin() != *output->quantization()->scale()->begin())
86
87 if (*tensor->quantization()->zero_point()->begin() !=
88 *output->quantization()->zero_point()->begin())
90 }
91#endif // DIS_QUANT
92
93 return Ok;
94}
const circle::Operator * first_operator
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
@ FailedCheckCondition
Definition OMStatus.h:32