36 const llvm::BitVector &indicesToDrop) {
39 int lastIndex = indicesToDrop.find_last();
41 assert((
size_t)lastIndex < input.size() &&
"index out of range");
51 size_t lastCopied = 0;
52 SmallVector<T> result;
53 result.reserve(input.size() - indicesToDrop.count());
55 for (
unsigned indexToDrop : indicesToDrop.set_bits()) {
57 if (indexToDrop > lastCopied) {
58 result.append(input.begin() + lastCopied, input.begin() + indexToDrop);
59 lastCopied = indexToDrop;
66 if (lastCopied < input.size())
67 result.append(input.begin() + lastCopied, input.end());
82 ResultTy init, ReduceFuncTy reduce,
83 TransformFuncTy transform) {
85 if (
context->isMultithreadingEnabled())
86 return llvm::parallelTransformReduce(begin, end, init, reduce, transform);
89 for (IterTy i = begin; i != end; ++i)
90 init = reduce(std::move(init), transform(*i));
91 return std::move(init);
static std::unique_ptr< Context > context
static ResultTy transformReduce(MLIRContext *context, IterTy begin, IterTy end, ResultTy init, ReduceFuncTy reduce, TransformFuncTy transform)
Wrapper for llvm::parallelTransformReduce that performs the transform_reduce serially when MLIR multi...
static SmallVector< T > removeElementsAtIndices(ArrayRef< T > input, const llvm::BitVector &indicesToDrop)
Remove elements from the input array corresponding to set bits in indicesToDrop, returning the elemen...