ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Shape.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
23
24using namespace onert_micro;
25using namespace onert_micro::execute;
26
27namespace
28{
29
30constexpr uint32_t inputTensorIdx = 0;
31constexpr uint32_t outputTensorIdx = 0;
32
33} // namespace
34
35// NOTE: doesnt currently support dynamic shapes
36namespace onert_micro
37{
38namespace execute
39{
40
42{
43 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
44 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
45 uint16_t op_index = execute_args.kernel_index;
46
47 const circle::Tensor *input = nullptr;
48 uint8_t *output_data = nullptr;
49
50 OMStatus status = Ok;
51 {
52 OMRuntimeKernel runtime_kernel;
53 runtime_kernel.readKernel(op_index, runtime_context);
54
55 input = runtime_kernel.inputs[inputTensorIdx];
56
57 assert(input != nullptr);
58
59 status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
60 if (status != Ok)
61 return status;
62
63 output_data = runtime_kernel.outputs_data[outputTensorIdx];
64 }
65
66 assert(output_data != nullptr);
67
68 core::OMRuntimeShape input_shape(input);
69
70 const auto rank = input_shape.dimensionsCount();
71
72 auto output_data_int = core::utils::castOutputData<int32_t>(output_data);
73
74 for (int i = 0; i < rank; ++i)
75 {
76 output_data_int[i] = input_shape.dims(i);
77 }
78
79 return status;
80}
81
82} // namespace execute
83} // namespace onert_micro
size_t dimensionsCount() const noexcept
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 * inputs[maxInputSize]
constexpr uint32_t outputTensorIdx
OMStatus execute_kernel_CircleShape(const OMExecuteArgs &execute_args)
Definition Shape.cpp:41
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage