coordinate.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 <algorithm>
20 #include <vector>
21 
22 #include "ngraph/attribute_adapter.hpp"
23 #include "ngraph/axis_set.hpp"
24 #include "ngraph/shape.hpp"
25 
26 namespace ngraph
27 {
28  /// \brief Coordinates for a tensor element
29  class Coordinate : public std::vector<size_t>
30  {
31  public:
32  NGRAPH_API Coordinate();
33  NGRAPH_API Coordinate(const std::initializer_list<size_t>& axes);
34 
35  NGRAPH_API Coordinate(const Shape& shape);
36 
37  NGRAPH_API Coordinate(const std::vector<size_t>& axes);
38 
39  NGRAPH_API Coordinate(const Coordinate& axes);
40 
41  NGRAPH_API Coordinate(size_t n, size_t initial_value = 0);
42 
43  NGRAPH_API ~Coordinate();
44 
45  template <class InputIterator>
46  Coordinate(InputIterator first, InputIterator last)
47  : std::vector<size_t>(first, last)
48  {
49  }
50 
51  NGRAPH_API Coordinate& operator=(const Coordinate& v);
52 
53  NGRAPH_API Coordinate& operator=(Coordinate&& v) noexcept;
54  };
55 
56  template <>
57  class NGRAPH_API AttributeAdapter<Coordinate>
58  : public IndirectVectorValueAccessor<Coordinate, std::vector<int64_t>>
59  {
60  public:
63  {
64  }
65 
66  static constexpr DiscreteTypeInfo type_info{"AttributeAdapter<Coordinate>", 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 Coordinate& coordinate);
72 }
An AttributeAdapter "captures" an attribute as an AT& and makes it available as a ValueAccessor<VAT>.
Definition: attribute_adapter.hpp:171
Coordinates for a tensor element.
Definition: coordinate.hpp:30
Definition: attribute_adapter.hpp:137
Shape for a tensor.
Definition: shape.hpp:31
The Intel nGraph C++ API.
Definition: attribute_adapter.hpp:28
Definition: type.hpp:39