ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Convert.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 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 "Convert.h"
18
20
21#include <schema_generated.h>
22
23using namespace nncc::core::ADT;
24
25namespace tflimport
26{
27
29{
30 const uint32_t size = array->size();
31
32 std::vector<int32_t> res(size);
33
34 for (uint32_t i = 0; i < size; i++)
35 {
36 res[i] = array->Get(i);
37 }
38
39 return res;
40}
41
43{
44 const uint32_t rank = shape->size();
45
46 tensor::Shape res;
47
48 res.resize(rank);
49 for (uint32_t axis = 0; axis < rank; ++axis)
50 {
51 res.dim(axis) = shape->Get(axis);
52 }
53
54 return res;
55}
56
57} // namespace tflimport
return_type Get(uoffset_t i) const
uoffset_t size() const
uint32_t & dim(uint32_t axis)
Definition Shape.cpp:42
Shape & resize(uint32_t size)
Definition Shape.cpp:36
std::vector< int32_t > IndexVector
Definition Convert.h:29
tensor::Shape as_tensor_shape(const flatbuffers::Vector< int32_t > *shape)
Converts flatbuffers::Vector to nncc::core::ADT::tensor::Shape.
Definition Convert.cpp:42
IndexVector as_index_vector(const flatbuffers::Vector< int32_t > *array)
Converts flatbuffers::Vector to IndexVector.
Definition Convert.cpp:28
int32_t size[5]
Definition Slice.cpp:35