ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Fill.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
17#include "OMStatus.h"
18
19#include "core/OMUtils.h"
20#include "core/OMKernelData.h"
21
24#include "PALFill.h"
25
26using namespace onert_micro;
27using namespace onert_micro::core;
28using namespace onert_micro::execute;
29
30namespace
31{
32
33constexpr uint32_t valueTensorIdx = 1;
34constexpr uint32_t outputTensorIdx = 0;
35
36} // namespace
37
38// NOTE: doesn't currently support dynamic shapes
39OMStatus onert_micro::execute::execute_kernel_CircleFill(const OMExecuteArgs &execute_args)
40{
41 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
42 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
43 uint16_t op_index = execute_args.kernel_index;
44
45 const circle::Tensor *value;
46 const circle::Tensor *output;
47
48 uint8_t *value_data;
49 uint8_t *output_data;
50
51 // Read kernel
52 {
53 execute::OMRuntimeKernel runtime_kernel;
54 OMStatus status = runtime_kernel.readKernel(op_index, runtime_context);
55 if (status != Ok)
56 return status;
57
58 value = runtime_kernel.inputs[valueTensorIdx];
59 output = runtime_kernel.outputs[outputTensorIdx];
60 assert(value != nullptr);
61 assert(output != nullptr);
62
63 status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
64 if (status != Ok)
65 return status;
66
67 value_data = runtime_kernel.inputs_data[valueTensorIdx];
69 assert(value_data != nullptr);
70 assert(output_data != nullptr);
71 }
72
73 OMStatus status = Ok;
74
75 assert(OMRuntimeShape(value).flatSize() == 1);
77
78 switch (output->type())
79 {
80#ifndef DIS_FLOAT
81 case circle::TensorType_FLOAT32:
82 {
83 status = pal::Fill(core::utils::castInputData<float>(value_data), output_shape,
84 core::utils::castOutputData<float>(output_data));
85 }
86 break;
87#endif // DIS_FLOAT
88 case circle::TensorType_INT32:
89 {
90 status = pal::Fill(core::utils::castInputData<int32_t>(value_data), output_shape,
91 core::utils::castOutputData<int32_t>(output_data));
92 }
93 break;
94 default:
95 {
96 status = UnsupportedActivation;
97 assert(false && "Unsupported type.");
98 break;
99 }
100 }
101
102 return status;
103}
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 circle::Tensor * inputs[maxInputSize]
const luci_interpreter::RuntimeShape output_shape
constexpr uint32_t outputTensorIdx
OMStatus Fill(const T *input_data, const core::OMRuntimeShape &output_shape, T *output_data)
Definition PALFill.h:32
@ UnsupportedActivation
Definition OMStatus.h:28
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage