-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removes array_ref::{operator==, operator!=} #108
Open
jiawen
wants to merge
2
commits into
master
Choose a base branch
from
jiawen-remove_eq
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,13 +458,13 @@ class dim : protected interval<Min_, Extent_> { | |
using base_range::begin; | ||
using base_range::end; | ||
using base_range::extent; | ||
using base_range::size; | ||
using base_range::is_in_range; | ||
using base_range::max; | ||
using base_range::min; | ||
using base_range::set_extent; | ||
using base_range::set_max; | ||
using base_range::set_min; | ||
using base_range::size; | ||
|
||
/** Get or set the distance in flat indices between neighboring elements | ||
* in this dim. */ | ||
|
@@ -560,9 +560,7 @@ class split_iterator { | |
split_iterator<InnerExtent> result(*this); | ||
return result += n; | ||
} | ||
NDARRAY_HOST_DEVICE split_iterator& operator++() { | ||
return *this += 1; | ||
} | ||
NDARRAY_HOST_DEVICE split_iterator& operator++() { return *this += 1; } | ||
NDARRAY_HOST_DEVICE split_iterator operator++(int) { | ||
split_iterator<InnerExtent> result(*this); | ||
*this += 1; | ||
|
@@ -612,15 +610,13 @@ class split_result { | |
* - `split<5>(interval<>(0, 12))` produces the intervals `[0, 5)`, | ||
* `[5, 10)`, `[7, 12)`. Note the last two intervals overlap. */ | ||
template <index_t InnerExtent, index_t Min, index_t Extent> | ||
NDARRAY_HOST_DEVICE internal::split_result<InnerExtent> split( | ||
const interval<Min, Extent>& v) { | ||
NDARRAY_HOST_DEVICE internal::split_result<InnerExtent> split(const interval<Min, Extent>& v) { | ||
assert(v.extent() >= InnerExtent); | ||
return {{fixed_interval<InnerExtent>(v.min()), v.max()}, | ||
{fixed_interval<InnerExtent>(v.max() + 1), v.max()}}; | ||
} | ||
template <index_t InnerExtent, index_t Min, index_t Extent, index_t Stride> | ||
NDARRAY_HOST_DEVICE internal::split_result<InnerExtent> split( | ||
const dim<Min, Extent, Stride>& v) { | ||
NDARRAY_HOST_DEVICE internal::split_result<InnerExtent> split(const dim<Min, Extent, Stride>& v) { | ||
return split<InnerExtent>(interval<Min, Extent>(v.min(), v.extent())); | ||
} | ||
|
||
|
@@ -1031,10 +1027,12 @@ NDARRAY_HOST_DEVICE const DimsSrc& assert_dims_compatible(const DimsSrc& src) { | |
return src; | ||
} | ||
|
||
/** Return a tuple of generic `dims` with same min and extents and all strides set to `unresolved`. */ | ||
/** Return a tuple of generic `dims` with same min and extents and all strides set to `unresolved`. | ||
*/ | ||
template <class Dims, size_t... Is> | ||
auto bounds_tuple(const Dims& dims, index_sequence<Is...>) { | ||
return std::make_tuple(dim<>(std::get<Is>(dims).min(), std::get<Is>(dims).extent(), unresolved)...); | ||
return std::make_tuple( | ||
dim<>(std::get<Is>(dims).min(), std::get<Is>(dims).extent(), unresolved)...); | ||
} | ||
|
||
} // namespace internal | ||
|
@@ -2174,26 +2172,6 @@ class array_ref { | |
NDARRAY_HOST_DEVICE index_t rows() const { return shape_.rows(); } | ||
NDARRAY_HOST_DEVICE index_t columns() const { return shape_.columns(); } | ||
|
||
/** Compare the contents of this array_ref to `other`. For two array_refs to | ||
* be considered equal, they must have the same shape, and all elements | ||
* addressable by the shape must also be equal. */ | ||
// TODO: Maybe this should just check for equality of the shape and pointer, | ||
// and let the free function equal serve this purpose. | ||
NDARRAY_HOST_DEVICE bool operator!=(const array_ref& other) const { | ||
if (shape_ != other.shape_) { return true; } | ||
|
||
// TODO: This currently calls operator!= on all elements of the array_ref, | ||
// even after we find a non-equal element | ||
// (https://github.com/dsharlet/array/issues/4). | ||
bool result = false; | ||
copy_shape_traits<Shape, Shape>::for_each_value( | ||
shape_, base_, other.shape_, other.base_, [&](const_reference a, const_reference b) { | ||
if (a != b) { result = true; } | ||
}); | ||
return result; | ||
} | ||
NDARRAY_HOST_DEVICE bool operator==(const array_ref& other) const { return !operator!=(other); } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this build? It looks like travis stopped working (again). |
||
|
||
NDARRAY_HOST_DEVICE const array_ref<T, Shape>& ref() const { return *this; } | ||
|
||
/** Allow conversion from array_ref<T> to const_array_ref<T>. */ | ||
|
@@ -2983,7 +2961,8 @@ bool equal(const array<TA, ShapeA, AllocA>& a, const array<TB, ShapeB, AllocB>& | |
* `NewShape`. The new shape is copy constructed from `a.shape()`. */ | ||
template <class NewShape, class T, class OldShape> | ||
NDARRAY_HOST_DEVICE array_ref<T, NewShape> convert_shape(const array_ref<T, OldShape>& a) { | ||
return array_ref<T, NewShape>(a.base(), convert_shape<NewShape>(a.shape()), internal::no_resolve{}); | ||
return array_ref<T, NewShape>( | ||
a.base(), convert_shape<NewShape>(a.shape()), internal::no_resolve{}); | ||
} | ||
template <class NewShape, class T, class OldShape, class Allocator> | ||
array_ref<T, NewShape> convert_shape(array<T, OldShape, Allocator>& a) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.clang-format
did this. Happy to revert.