ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Helper.h
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#ifndef __MIO_CIRCLE08_HELPER_H__
18#define __MIO_CIRCLE08_HELPER_H__
19
20#include <mio/circle/schema_generated.h>
21
22#include <vector>
23
24namespace mio
25{
26namespace circle
27{
28
29::circle::BuiltinOperator builtin_code_neutral(const ::circle::OperatorCode *opcode);
30bool is_valid(const ::circle::OperatorCode *opcode);
31bool is_custom(const ::circle::OperatorCode *opcode);
32std::string opcode_name(const ::circle::OperatorCode *opcode);
33const char *tensor_type(const ::circle::Tensor *tensor);
34const char *tensor_name(const ::circle::Tensor *tensor);
35
36template <typename T> std::vector<T> as_index_vector(const flatbuffers::Vector<T> *flat_array)
37{
38 if (flat_array == nullptr)
39 {
40 throw std::runtime_error("flat array is nullptr");
41 }
42
43 std::vector<T> ret(flat_array->size());
44 for (uint32_t i = 0; i < flat_array->size(); i++)
45 {
46 ret[i] = flat_array->Get(i);
47 }
48 return ret;
49}
50
51} // namespace circle
52} // namespace mio
53
54#endif // __MIO_CIRCLE08_HELPER_H__
return_type Get(uoffset_t i) const
uoffset_t size() const
const char * tensor_name(const ::circle::Tensor *tensor)
Definition Helper.cpp:69
std::string opcode_name(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:38
std::vector< T > as_index_vector(const flatbuffers::Vector< T > *flat_array)
Definition Helper.h:36
const char * tensor_type(const ::circle::Tensor *tensor)
Definition Helper.cpp:64
bool is_custom(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:32
bool is_valid(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:26
::circle::BuiltinOperator builtin_code_neutral(const ::circle::OperatorCode *opcode)
Definition Helper.cpp:33
Definition Helper.h:23