coordinate_diff.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 difference (signed) of tensor element coordinates.
29  class CoordinateDiff : public std::vector<std::ptrdiff_t>
30  {
31  public:
32  NGRAPH_API CoordinateDiff(const std::initializer_list<std::ptrdiff_t>& diffs);
33 
34  NGRAPH_API CoordinateDiff(const std::vector<std::ptrdiff_t>& diffs);
35 
36  NGRAPH_API CoordinateDiff(const CoordinateDiff& diffs);
37 
38  NGRAPH_API explicit CoordinateDiff(size_t n, std::ptrdiff_t initial_value = 0);
39 
40  template <class InputIterator>
41  CoordinateDiff(InputIterator first, InputIterator last)
42  : std::vector<std::ptrdiff_t>(first, last)
43  {
44  }
45 
46  NGRAPH_API ~CoordinateDiff();
47 
48  NGRAPH_API CoordinateDiff();
49 
50  NGRAPH_API CoordinateDiff& operator=(const CoordinateDiff& v);
51 
52  NGRAPH_API CoordinateDiff& operator=(CoordinateDiff&& v) noexcept;
53  };
54 
55  template <>
56  class NGRAPH_API AttributeAdapter<CoordinateDiff>
57  : public IndirectVectorValueAccessor<CoordinateDiff, std::vector<int64_t>>
58 
59  {
60  public:
61  AttributeAdapter(CoordinateDiff& value)
62  : IndirectVectorValueAccessor<CoordinateDiff, std::vector<int64_t>>(value)
63  {
64  }
65 
66  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<CoordinateDiff>", 0};
67  const DiscreteTypeInfo& get_type_info() const override { return type_info; }
68  };
69 
70  NGRAPH_API
71  std::ostream& operator<<(std::ostream& s, const CoordinateDiff& coordinate_diff);
72 }
ngraph::CoordinateDiff
A difference (signed) of tensor element coordinates.
Definition: coordinate_diff.hpp:30
ngraph::DiscreteTypeInfo
Definition: type.hpp:39
ngraph
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28