ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Dequantize.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 inputTensorIdx = 0;
29constexpr uint32_t outputTensorIdx = 0;
30
31} // namespace
32
33OMStatus onert_micro::import::configure_kernel_CircleDequantize(const OMConfigureArgs &config_args)
34{
35 OMRuntimeContext &runtime_context = config_args.runtime_context;
36 uint16_t op_index = config_args.kernel_index;
37
39
40 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
41 if (status != Ok)
42 return status;
43
44 const circle::Tensor *input = runtime_kernel.inputs[inputTensorIdx];
45 const circle::Tensor *output = runtime_kernel.outputs[outputTensorIdx];
46
47 assert(input != nullptr);
48 assert(output != nullptr);
49
50 OMRuntimeShape input_shape(input);
52
53 // Check shapes
54 status = utils::checkCondition(input_shape == output_shape);
55 if (status != Ok)
56 return status;
57
58 // Check output type is float
59 status = utils::checkCondition(output->type() == circle::TensorType_FLOAT32);
60 if (status != Ok)
61 return status;
62
63 // Check input quantization params
64 const auto *input_quantization = input->quantization();
65 status = utils::checkCondition(input->type() != circle::TensorType_FLOAT32 or
66 input_quantization != nullptr and
67 input_quantization->scale() != nullptr and
68 input_quantization->scale()->size() == 1);
69 if (status != Ok)
70 return status;
71
72 return status;
73}
OMStatus readKernel(uint16_t op_index, core::OMRuntimeContext &runtime_context)
const circle::Tensor * outputs[maxOutputSize]
const circle::Tensor * inputs[maxInputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx