ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Shape.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2025 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 __CIRCLE_RESIZER_SHAPE_H__
18#define __CIRCLE_RESIZER_SHAPE_H__
19
20#include "Dim.h"
21
22#include <ostream>
23#include <vector>
24
25namespace circle_resizer
26{
27
31class Shape
32{
33public:
37 Shape(const std::initializer_list<Dim> &dims);
38
42 Shape(const std::vector<Dim> &shape_vec);
43
50 Shape(const std::initializer_list<uint32_t> &shape_vec);
51
55 static Shape scalar();
56
57public:
61 size_t rank() const;
62
70 Dim operator[](const size_t &axis) const;
71
75 bool is_scalar() const;
76
81 bool is_dynamic() const;
82
86 bool operator==(const Shape &rhs) const;
87
88private:
89 std::vector<Dim> _dims;
90};
91
95std::ostream &operator<<(std::ostream &os, const Shape &shape);
96
97} // namespace circle_resizer
98
99#endif // __CIRCLE_RESIZER_SHAPE_H__
bool is_scalar() const
Returns true if the shape is a scalar. Otherwise, return false.
Definition Shape.cpp:58
static Shape scalar()
Create scalar shape. Note, that the same can be achieved with Shape{}.
Definition Shape.cpp:40
bool is_dynamic() const
Returns true if all dimensions in the shape are static or the shape is a scalar. Otherwise,...
Definition Shape.cpp:60
Dim operator[](const size_t &axis) const
Returns dimension of the position determined by axis.
Definition Shape.cpp:44
size_t rank() const
Returns number of dimensions in the shape.
bool operator==(const Shape &rhs) const
Returns true of the current shape and the provided rhs are equal.
std::ostream & operator<<(std::ostream &os, const Shape &shape)
Print the shape in format [1, 2, 3].
Definition Shape.cpp:86