strides.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <cstddef>
8 #include <ostream>
9 #include <vector>
10 
11 #include "ngraph/attribute_adapter.hpp"
12 #include "ngraph/ngraph_visibility.hpp"
13 
14 namespace ngraph
15 {
16  /// \brief Strides for a tensor.
17  class Strides : public std::vector<size_t>
18  {
19  public:
20  NGRAPH_API Strides();
21 
22  NGRAPH_API Strides(const std::initializer_list<size_t>& axis_strides);
23 
24  NGRAPH_API Strides(const std::vector<size_t>& axis_strides);
25 
26  NGRAPH_API Strides(const Strides& axis_strides);
27 
28  NGRAPH_API explicit Strides(size_t n, size_t initial_value = 0);
29 
30  template <class InputIterator>
31  Strides(InputIterator first, InputIterator last)
32  : std::vector<size_t>(first, last)
33  {
34  }
35 
36  NGRAPH_API Strides& operator=(const Strides& v);
37 
38  NGRAPH_API Strides& operator=(Strides&& v) noexcept;
39  };
40 
41  template <>
42  class NGRAPH_API AttributeAdapter<Strides>
43  : public IndirectVectorValueAccessor<Strides, std::vector<int64_t>>
44 
45  {
46  public:
49  {
50  }
51  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<Strides>", 0};
52  const DiscreteTypeInfo& get_type_info() const override { return type_info; }
53  };
54 
55  NGRAPH_API
56  std::ostream& operator<<(std::ostream& s, const Strides& strides);
57 } // namespace ngraph
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:161
Definition: attribute_adapter.hpp:126
Strides for a tensor.
Definition: strides.hpp:18
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:16
Definition: type.hpp:27