Fix empty subspan. (#4151)

* Silent the death tests.
This commit is contained in:
Jiaming Yuan
2019-02-17 04:48:03 +08:00
committed by GitHub
parent ff2d4c99fa
commit 1fe874e58a
3 changed files with 51 additions and 9 deletions

View File

@@ -69,6 +69,7 @@ namespace common {
// Usual logging facility is not available inside device code.
// TODO(trivialfis): Make dmlc check more generic.
// assert is not supported in mac as of CUDA 10.0
#define KERNEL_CHECK(cond) \
do { \
if (!(cond)) { \
@@ -543,7 +544,7 @@ class Span {
XGBOOST_DEVICE auto subspan() const -> // NOLINT
Span<element_type,
detail::ExtentValue<Extent, Offset, Count>::value> {
SPAN_CHECK(Offset >= 0 && Offset < size());
SPAN_CHECK(Offset >= 0 && (Offset < size() || size() == 0));
SPAN_CHECK(Count == dynamic_extent ||
Count >= 0 && Offset + Count <= size());
@@ -553,7 +554,7 @@ class Span {
XGBOOST_DEVICE Span<element_type, dynamic_extent> subspan( // NOLINT
detail::ptrdiff_t _offset,
detail::ptrdiff_t _count = dynamic_extent) const {
SPAN_CHECK(_offset >= 0 && _offset < size());
SPAN_CHECK(_offset >= 0 && (_offset < size() || size() == 0));
SPAN_CHECK((_count == dynamic_extent) ||
(_count >= 0 && _offset + _count <= size()));