strides.hpp
1 //*****************************************************************************
2 // Copyright 2017-2021 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 Strides for a tensor.
29  class Strides : public std::vector<size_t>
30  {
31  public:
32  NGRAPH_API Strides();
33 
34  NGRAPH_API Strides(const std::initializer_list<size_t>& axis_strides);
35 
36  NGRAPH_API Strides(const std::vector<size_t>& axis_strides);
37 
38  NGRAPH_API Strides(const Strides& axis_strides);
39 
40  NGRAPH_API explicit Strides(size_t n, size_t initial_value = 0);
41 
42  template <class InputIterator>
43  Strides(InputIterator first, InputIterator last)
44  : std::vector<size_t>(first, last)
45  {
46  }
47 
48  NGRAPH_API Strides& operator=(const Strides& v);
49 
50  NGRAPH_API Strides& operator=(Strides&& v) noexcept;
51  };
52 
53  template <>
54  class NGRAPH_API AttributeAdapter<Strides>
55  : public IndirectVectorValueAccessor<Strides, std::vector<int64_t>>
56 
57  {
58  public:
61  {
62  }
63  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<Strides>", 0};
64  const DiscreteTypeInfo& get_type_info() const override { return type_info; }
65  };
66 
67  NGRAPH_API
68  std::ostream& operator<<(std::ostream& s, const Strides& strides);
69 }
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:171
Definition: attribute_adapter.hpp:137
Strides for a tensor.
Definition: strides.hpp:30
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39