axis_vector.hpp
1 //*****************************************************************************
2 // Copyright 2017-2020 Intel Corporation
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 #pragma once
18 
19 #include <cstddef>
20 #include <ostream>
21 #include <vector>
22 
23 #include "ngraph/attribute_adapter.hpp"
24 #include "ngraph/ngraph_visibility.hpp"
25 
26 namespace ngraph
27 {
28  /// \brief A vector of axes.
29  class AxisVector : public std::vector<size_t>
30  {
31  public:
32  NGRAPH_API AxisVector(const std::initializer_list<size_t>& axes);
33 
34  NGRAPH_API AxisVector(const std::vector<size_t>& axes);
35 
36  NGRAPH_API AxisVector(const AxisVector& axes);
37 
38  NGRAPH_API explicit AxisVector(size_t n);
39 
40  template <class InputIterator>
41  AxisVector(InputIterator first, InputIterator last)
42  : std::vector<size_t>(first, last)
43  {
44  }
45 
46  NGRAPH_API AxisVector();
47 
48  NGRAPH_API ~AxisVector();
49 
50  NGRAPH_API AxisVector& operator=(const AxisVector& v);
51 
52  NGRAPH_API AxisVector& operator=(AxisVector&& v) noexcept;
53  };
54 
55  template <>
56  class NGRAPH_API AttributeAdapter<AxisVector>
57  : public IndirectVectorValueAccessor<AxisVector, std::vector<int64_t>>
58  {
59  public:
62  {
63  }
64 
65  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<AxisVector>", 0};
66  const DiscreteTypeInfo& get_type_info() const override { return type_info; }
67  };
68 
69  NGRAPH_API
70  std::ostream& operator<<(std::ostream& s, const AxisVector& axis_vector);
71 }
ngraph::AxisVector
A vector of axes.
Definition: axis_vector.hpp:30
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
ngraph::AttributeAdapter
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:170
ngraph::IndirectVectorValueAccessor
Definition: attribute_adapter.hpp:136