1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief a header file for describing property style structure used by CNNLayers
14 namespace InferenceEngine {
16 constexpr const int MAX_DIMS_NUMBER = 12;
18 enum eDIMS_AXIS : uint8_t { X_AXIS = 0, Y_AXIS, Z_AXIS };
20 template <class T, int N = MAX_DIMS_NUMBER>
21 class PropertyVector {
23 bool _allocated[N] = {};
27 PropertyVector() = default;
29 PropertyVector(size_t len, T val) {
31 THROW_IE_EXCEPTION << "Property size exceeed limit of: " << N;
33 for (size_t i = 0; i < len; i++) {
40 explicit PropertyVector(const std::vector<T>& values) {
42 for (const auto val : values) {
47 PropertyVector(std::initializer_list<int> init_list) {
49 for (const auto val : init_list) {
55 * @brief allows access up-to capacity size
62 THROW_IE_EXCEPTION << "Property index is out of bounds (" << index << "/" << N;
64 return _axises[index];
67 const T& operator[](size_t index) const {
68 if (index >= N || !_allocated[index]) {
69 THROW_IE_EXCEPTION << "Property index (" << index << ") is out of bounds";
71 return _axises[index];
74 T& operator[](size_t index) {
75 if (index >= N || !_allocated[index]) {
76 THROW_IE_EXCEPTION << "Property index (" << index << ") is out of bounds";
78 return _axises[index];
81 PropertyVector& operator=(const PropertyVector& src) {
84 for (size_t i = 0; i < N; i++) {
85 _allocated[i] = src._allocated[i];
94 bool operator==(const PropertyVector& src) const {
95 if (this == &src) return true;
96 if (_length != src.size()) return false;
97 for (size_t i = 0; i < N; i++)
98 if ((_allocated[i] != src._allocated[i]) || (_allocated[i] && _axises[i] != src._axises[i])) return false;
102 size_t size() const {
106 void insert(size_t axis, const T& val) {
108 if (!_allocated[axis]) {
109 _allocated[axis] = true;
114 THROW_IE_EXCEPTION << "Layer Property insertion at(axis) should be in [0," << N << ")";
118 void remove(size_t axis) {
119 if (axis < N && _allocated[axis]) {
120 _allocated[axis] = false;
126 for (int i = 0; i != N; i++) {
132 bool exist(size_t axis) const {
133 return (axis < N && _allocated[axis]);
137 } // namespace InferenceEngine