2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __LOCO_IR_DIMENSION_H__
18 #define __LOCO_IR_DIMENSION_H__
26 * @brief The value of one dimension in a tensor shape
27 * @note The value may be unknown
39 /// @brief Construct an "unknown" dimension
40 Dimension() = default;
42 /// @brief Construct a "known" dimension
43 Dimension(uint32_t value) { set(value); }
46 /// @brief Return whether the value is known (or not)
47 bool known(void) const { return _kind == Kind::Known; }
49 /// @brief Return the value
50 /// @note This value is meaningful only for known dimension
51 uint32_t value(void) const { return _value; }
53 void set(uint32_t value)
61 _kind = Kind::Unknown;
66 Kind _kind{Kind::Unknown};
71 * @brief Equality operator between two Dimensions
73 * @note Refer to the definition of equality of dimemsion at
74 * https://www.tensorflow.org/api_docs/python/tf/Dimension#__eq__
76 bool operator==(const Dimension &, const Dimension &);
77 bool operator==(const Dimension &, uint32_t);
78 bool operator==(uint32_t, const Dimension &);
80 /// @brief Make an "unknown" dimension
81 Dimension make_dimension(void);
85 #endif // __LOCO_IR_DIMENSION_H__