ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnapi.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 "morph/nnapi.h"
18
19#include <cassert>
20
21using namespace nncc::core::ADT;
22
23namespace morph
24{
25namespace nnapi
26{
27
29{
30 tensor::Shape res;
31
32 res.resize(4);
33 res.dim(0) = 1;
34 res.dim(1) = shape.height();
35 res.dim(2) = shape.width();
36 res.dim(3) = shape.depth();
37
38 return res;
39}
40
42{
43 tensor::Shape res;
44
45 res.resize(4);
46 res.dim(0) = shape.count();
47 res.dim(1) = shape.height();
48 res.dim(2) = shape.width();
49 res.dim(3) = shape.depth();
50
51 return res;
52}
53
55{
56 assert(shape.rank() == 4);
57 assert(shape.dim(0) == 1);
58 return feature::Shape{shape.dim(3), shape.dim(1), shape.dim(2)};
59}
60
62{
63 assert(shape.rank() == 4);
64 return kernel::Shape{shape.dim(0), shape.dim(3), shape.dim(1), shape.dim(2)};
65}
66
67} // namespace nnapi
68} // namespace morph
uint32_t depth(void) const
Definition Shape.h:44
uint32_t width(void) const
Definition Shape.h:46
uint32_t height(void) const
Definition Shape.h:45
uint32_t width(void) const
Definition Shape.h:47
uint32_t height(void) const
Definition Shape.h:46
uint32_t count(void) const
Definition Shape.h:44
uint32_t depth(void) const
Definition Shape.h:45
uint32_t & dim(uint32_t axis)
Definition Shape.cpp:42
Shape & resize(uint32_t size)
Definition Shape.cpp:36
uint32_t rank(void) const
Definition Shape.cpp:35
nncc::core::ADT::kernel::Shape as_kernel_shape(const nncc::core::ADT::tensor::Shape &)
Definition nnapi.cpp:61
nncc::core::ADT::tensor::Shape as_tensor_shape(const nncc::core::ADT::feature::Shape &)
Definition nnapi.cpp:28
nncc::core::ADT::feature::Shape as_feature_shape(const nncc::core::ADT::tensor::Shape &)
Definition nnapi.cpp:54
Definition caffe.h:25