| 73 | } |
| 74 | |
| 75 | TensorSliceView TensorSliceView::Intersect(const TensorSliceView& other) const { |
| 76 | if (IsEmpty() || other.IsEmpty()) { return TensorSliceView(); } |
| 77 | CHECK_EQ(other.range_vec_.size(), range_vec_.size()); |
| 78 | std::vector<Range> intersection_vec; |
| 79 | intersection_vec.reserve(range_vec_.size()); |
| 80 | const Range zero(0, 0); |
| 81 | FOR_RANGE(int64_t, i, 0, range_vec_.size()) { |
| 82 | const Range intersection = FindIntersectant(range_vec_.at(i), other.range_vec_.at(i)); |
| 83 | if (intersection == zero) { |
| 84 | return TensorSliceView(); |
| 85 | } else { |
| 86 | intersection_vec.emplace_back(intersection); |
| 87 | } |
| 88 | } |
| 89 | return TensorSliceView(intersection_vec); |
| 90 | } |
| 91 | |
| 92 | const Range& TensorSliceView::At(int64_t index) const { return range_vec_.at(index); } |
| 93 |
no test coverage detected