Poplar and PopLibs
VariableRef.hpp
1// Copyright (c) 2018 Graphcore Ltd. All rights reserved.
2
3#ifndef poplar_VariableRef_hpp
4#define poplar_VariableRef_hpp
5
6#include <poplar/Interval.hpp>
7#include <poplar/Tensor.hpp>
8
9namespace poplar {
10
13 unsigned id;
14
15public:
16 VariableRef(unsigned id) : id(id) {}
17 VariableRef() = default;
18 VariableRef(const VariableRef &other) = default;
19 VariableRef(VariableRef &&other) = default;
20 VariableRef &operator=(const VariableRef &other) = default;
21 VariableRef &operator=(VariableRef &&other) = default;
22
23 friend bool operator==(const VariableRef &a, const VariableRef &b) {
24 return a.id == b.id;
25 }
26
27 friend bool operator<(const VariableRef &a, const VariableRef &b) {
28 return a.id < b.id;
29 }
30
31 std::size_t hash() const;
32
33 friend class Graph;
34};
35
38 VariableRef var;
39 Interval interval;
41 : var(var), interval(std::move(interval)) {}
42 VariableInterval() = default;
43 VariableInterval(const VariableInterval &other) = default;
44 VariableInterval(VariableInterval &&other) = default;
45 VariableInterval &operator=(const VariableInterval &other) = default;
46 VariableInterval &operator=(VariableInterval &&other) = default;
47};
48
49bool operator==(const VariableInterval &a, const VariableInterval &b);
50bool operator<(const VariableInterval &a, const VariableInterval &b);
51
52} // end namespace poplar
53
54namespace std {
55
56template <> struct hash<poplar::VariableRef> {
57 size_t operator()(const poplar::VariableRef &v) const { return v.hash(); }
58};
59
60} // namespace std
61
62#endif // poplar_VariableRef_hpp
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
Type representing a reference to a variable in a graph.
Definition: VariableRef.hpp:12
Poplar classes and functions.
Definition: ArrayRef.hpp:14
Type representing a segment of a particular variable.
Definition: VariableRef.hpp:37