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
36OMStatus onert_micro::execute::execute_kernel_CircleShape(const OMExecuteArgs &execute_args)
37{
38 core::OMRuntimeContext &runtime_context = execute_args.runtime_context;
39 core::OMRuntimeStorage &runtime_storage = execute_args.runtime_storage;
40 uint16_t op_index = execute_args.kernel_index;
41
42 const circle::Tensor *input = nullptr;
43 uint8_t *output_data = nullptr;
44
45 OMStatus status = Ok;
46 {
47 OMRuntimeKernel runtime_kernel;
48 runtime_kernel.readKernel(op_index, runtime_context);
49
50 input = runtime_kernel.inputs[inputTensorIdx];
51
52 assert(input != nullptr);
53
54 status = runtime_kernel.getDataFromStorage(op_index, runtime_storage, runtime_context);
55 if (status != Ok)
56 return status;
57
59 }
60
61 assert(output_data != nullptr);
62
63 core::OMRuntimeShape input_shape(input);
64
65 const auto rank = input_shape.dimensionsCount();
66
67 auto output_data_int = core::utils::castOutputData<int32_t>(output_data);
68
69 for (int i = 0; i < rank; ++i)
70 {
71 output_data_int[i] = input_shape.dims(i);
72 }
73
74 return status;
75}
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
core::OMRuntimeContext & runtime_context
core::OMRuntimeStorage & runtime_storage