1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
6 * @brief a header file for describing property style structure used by CNNLayers
7 * @file ie_layers_property.h
13 namespace InferenceEngine {
15 constexpr const int MAX_DIMS_NUMBER = 12;
17 enum eDIMS_AXIS : uint8_t {
23 template<class T, int N = MAX_DIMS_NUMBER>
24 class PropertyVector {
26 bool _allocated[N] = {};
30 PropertyVector() = default;
32 PropertyVector(size_t len, T val) {
34 THROW_IE_EXCEPTION << "Property size exceeed limit of: " << N;
36 for (size_t i = 0; i < len; i++) {
43 explicit PropertyVector(const std::vector<T>& values) {
45 for (const auto val : values) {
50 PropertyVector(std::initializer_list<int> init_list) {
52 for (const auto val : init_list) {
58 * @brief allows access up-to capacity size
64 THROW_IE_EXCEPTION << "Property index is out of bounds(" << index << "/" << N;
66 return _axises[index];
69 const T &operator[](size_t index) const {
70 if (index >= N ||!_allocated[index]) {
71 THROW_IE_EXCEPTION << "Property index ("<< index <<")is out of bounds";
73 return _axises[index];
76 T &operator[](size_t index) {
77 if (index >= N || !_allocated[index]) {
78 THROW_IE_EXCEPTION << "Property index ("<< index <<")is out of bounds";
80 return _axises[index];
83 PropertyVector &operator=(const PropertyVector &src) {
86 for (size_t i = 0; i < N; i++) {
87 _allocated[i] = src._allocated[i];
96 bool operator==(const PropertyVector& src) const {
97 if (this == &src) return true;
98 if (_length != src.size()) return false;
99 for (size_t i = 0; i < N; i++)
100 if ((_allocated[i] != src._allocated[i]) ||
101 (_allocated[i] && _axises[i] != src._axises[i])) return false;
105 size_t size() const {
109 void insert(size_t axis, const T &val) {
111 if (!_allocated[axis]) {
112 _allocated[axis] = true;
117 THROW_IE_EXCEPTION << "Layer Property insertion at(axis) should be in [0,"<< N<< ")";
121 void remove(size_t axis) {
122 if (axis < N && _allocated[axis]) {
123 _allocated[axis] = false;
129 for (int i = 0; i != N; i++) {
135 bool exist(size_t axis) const {
136 return (axis < N && _allocated[axis]);
140 } // namespace InferenceEngine