ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Shape.cpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 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 "Shape.h"
18
19namespace luci
20{
21
22bool is_same_shape(const luci::CircleNode *node, const loco::TensorShape &shape)
23{
24 if (node == nullptr)
25 return false;
26
28 return false;
29
30 if (node->rank() != shape.rank())
31 return false;
32
33 for (uint32_t i = 0; i < node->rank(); ++i)
34 {
35 if (node->dim(i).known() != shape.dim(i).known())
36 return false;
37
38 if (node->dim(i).value() != shape.dim(i).value())
39 return false;
40 }
41
42 return true;
43}
44
45bool is_same_shape(const luci::CircleNode *node, const std::initializer_list<uint32_t> shape)
46{
47 if (node == nullptr)
48 return false;
49
50 if (node->rank() != shape.size())
51 return false;
52
53 uint32_t i = 0;
54 for (auto it = shape.begin(); it != shape.end(); ++it, ++i)
55 {
56 if (node->dim(i).value() != *it)
57 return false;
58 }
59 return true;
60}
61
63{
64 const auto circle_node = loco::must_cast<const luci::CircleNode *>(node);
65 for (uint32_t i = 0; i < circle_node->rank(); ++i)
66 if (!circle_node->dim(i).known())
67 return true;
68 return false;
69}
70
71} // namespace luci
uint32_t value(void) const
Return the value.
Definition Dimension.h:51
bool known(void) const
Return whether the value is known (or not)
Definition Dimension.h:47
Logical unit of computation.
Definition Node.h:54
const Dimension & dim(uint32_t axis) const
Definition TensorShape.h:38
uint32_t rank(void) const
Definition TensorShape.h:35
bool has_dynamic_shape(const loco::Node *node)
Definition Shape.cpp:62
bool is_same_shape(const luci::CircleNode *node, const loco::TensorShape &shape)
Definition Shape.cpp:22
ShapeStatus shape_status(void) const