[AutoDiff upstream] NFC: update IndexSubset print/dump utilities. (#27775)

Cherry-pick #27772 from tensorflow branch.
This commit is contained in:
Dan Zheng
2019-10-18 14:01:28 -07:00
committed by GitHub
parent 33e5c0db3c
commit 7b5dfd6cf6
2 changed files with 18 additions and 13 deletions

View File

@@ -79,6 +79,20 @@ IndexSubset *IndexSubset::extendingCapacity(
return IndexSubset::get(ctx, indices);
}
void IndexSubset::print(llvm::raw_ostream &s) const {
s << '{';
interleave(range(capacity), [this, &s](unsigned i) { s << contains(i); },
[&s] { s << ", "; });
s << '}';
}
void IndexSubset::dump(llvm::raw_ostream &s) const {
s << "(index_subset capacity=" << capacity << " indices=(";
interleave(getIndices(), [&s](unsigned i) { s << i; },
[&s] { s << ", "; });
s << "))\n";
}
int IndexSubset::findNext(int startIndex) const {
assert(startIndex < (int)capacity && "Start index cannot be past the end");
unsigned bitWordIndex = 0, offset = 0;