TVM  0.9.4
Range.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/api.h>
6 
7 #include <Eigen/Core>
8 
9 #include <memory>
10 #include <string>
11 #include <vector>
12 
13 namespace tvm
14 {
19 {
20 public:
21  Range() : start(0), dim(0) {}
22  Range(int s, int d) : start(s), dim(d) { assert(d >= 0); }
23  int start;
24  int dim;
25 
27  int end() const { return start + dim; }
28 
29  bool operator==(const Range & other) const { return this->dim == other.dim && this->start == other.start; }
30 
31  bool operator!=(const Range & other) const { return !operator==(other); }
32 
34  bool contains(int i) const { return start <= i && i < end(); }
35 
40  bool contains(const Range & other) const { return this->contains(other.start) && this->end() >= other.end(); }
41 
43  bool intersects(const Range & other) const { return this->contains(other.start) || other.contains(this->start); }
44 
46  Range operator+(int i) const { return {this->start + i, this->dim}; }
47 
49  Range operator-(int i) const { return {this->start - i, this->dim}; }
50 
55  Range relativeRange(const Range & other) const
56  {
57  assert(this->contains(other));
58  return other - this->start;
59  }
60 };
61 
62 } // namespace tvm
#define TVM_DLLAPI
Definition: api.h:35
Definition: Range.h:19
Range relativeRange(const Range &other) const
Definition: Range.h:55
int end() const
Definition: Range.h:27
Range(int s, int d)
Definition: Range.h:22
int dim
Definition: Range.h:24
bool contains(const Range &other) const
Definition: Range.h:40
bool intersects(const Range &other) const
Definition: Range.h:43
Range()
Definition: Range.h:21
bool operator==(const Range &other) const
Definition: Range.h:29
bool contains(int i) const
Definition: Range.h:34
int start
Definition: Range.h:23
bool operator!=(const Range &other) const
Definition: Range.h:31
Range operator-(int i) const
Definition: Range.h:49
Range operator+(int i) const
Definition: Range.h:46
Definition: Clock.h:12
bool operator==(const Variable &u, const Variable &v)
Definition: Variable.h:327