Skip to content

[mlir] Construct SmallVector with ArrayRef (NFC) #101896

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct UnrollVectorOptions {

/// Set the native shape to use for unrolling.
UnrollVectorOptions &setNativeShape(ArrayRef<int64_t> shape) {
SmallVector<int64_t> tsShape(shape.begin(), shape.end());
SmallVector<int64_t> tsShape(shape);
nativeShape = [=](Operation *) -> std::optional<SmallVector<int64_t>> {
return tsShape;
};
Expand Down
2 changes: 1 addition & 1 deletion mlir/include/mlir/IR/DialectRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DialectExtensionBase {
/// If the list is empty, the extension is invoked for every loaded dialect
/// independently.
DialectExtensionBase(ArrayRef<StringRef> dialectNames)
: dialectNames(dialectNames.begin(), dialectNames.end()) {}
: dialectNames(dialectNames) {}

private:
/// The names of the dialects affected by this extension.
Expand Down
3 changes: 1 addition & 2 deletions mlir/include/mlir/TableGen/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ class MethodSignature {
ArrayRef<MethodParameter> parameters)
: MethodSignature(std::forward<RetTypeT>(retType),
std::forward<NameT>(name),
SmallVector<MethodParameter>(parameters.begin(),
parameters.end())) {}
SmallVector<MethodParameter>(parameters)) {}
/// Create a method signature with a return type, a method name, and a
/// variadic list of parameters.
template <typename RetTypeT, typename NameT, typename... Parameters>
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Analysis/Presburger/IntegerRelation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1515,7 +1515,7 @@ void IntegerRelation::addLocalFloorDiv(ArrayRef<DynamicAPInt> dividend,

appendVar(VarKind::Local);

SmallVector<DynamicAPInt, 8> dividendCopy(dividend.begin(), dividend.end());
SmallVector<DynamicAPInt, 8> dividendCopy(dividend);
dividendCopy.insert(dividendCopy.end() - 1, DynamicAPInt(0));
addInequality(
getDivLowerBound(dividendCopy, divisor, dividendCopy.size() - 2));
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Analysis/Presburger/Simplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ void SimplexBase::addDivisionVariable(ArrayRef<DynamicAPInt> coeffs,
assert(denom > 0 && "Denominator must be positive!");
appendVariable();

SmallVector<DynamicAPInt, 8> ineq(coeffs.begin(), coeffs.end());
SmallVector<DynamicAPInt, 8> ineq(coeffs);
DynamicAPInt constTerm = ineq.back();
ineq.back() = -denom;
ineq.emplace_back(constTerm);
Expand Down Expand Up @@ -1754,7 +1754,7 @@ class presburger::GBRSimplex {
getCoeffsForDirection(ArrayRef<DynamicAPInt> dir) {
assert(2 * dir.size() == simplex.getNumVariables() &&
"Direction vector has wrong dimensionality");
SmallVector<DynamicAPInt, 8> coeffs(dir.begin(), dir.end());
SmallVector<DynamicAPInt, 8> coeffs(dir);
coeffs.reserve(dir.size() + 1);
for (const DynamicAPInt &coeff : dir)
coeffs.emplace_back(-coeff);
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Analysis/Presburger/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ presburger::getDivUpperBound(ArrayRef<DynamicAPInt> dividend,
assert(divisor > 0 && "divisor must be positive!");
assert(dividend[localVarIdx] == 0 &&
"Local to be set to division must have zero coeff!");
SmallVector<DynamicAPInt, 8> ineq(dividend.begin(), dividend.end());
SmallVector<DynamicAPInt, 8> ineq(dividend);
ineq[localVarIdx] = -divisor;
return ineq;
}
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Conversion/VectorToGPU/VectorToGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static void getXferIndices(RewriterBase &rewriter, TransferOpType xferOp,
for (auto expr : xferOp.getPermutationMap().getResults()) {
if (auto dim = dyn_cast<AffineDimExpr>(expr)) {
Value prevIdx = indices[dim.getPosition()];
SmallVector<OpFoldResult, 3> dims(dimValues.begin(), dimValues.end());
SmallVector<OpFoldResult, 3> dims(dimValues);
dims.push_back(prevIdx);
AffineExpr d0 = rewriter.getAffineDimExpr(offsetMap.getNumDims());
indices[dim.getPosition()] = affine::makeComposedAffineApply(
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4146,11 +4146,9 @@ static ParseResult parseAffineMapWithMinMax(OpAsmParser &parser,
llvm::append_range(flatExprs, map.getValue().getResults());
auto operandsRef = llvm::ArrayRef(mapOperands);
auto dimsRef = operandsRef.take_front(map.getValue().getNumDims());
SmallVector<OpAsmParser::UnresolvedOperand> dims(dimsRef.begin(),
dimsRef.end());
SmallVector<OpAsmParser::UnresolvedOperand> dims(dimsRef);
auto symsRef = operandsRef.drop_front(map.getValue().getNumDims());
SmallVector<OpAsmParser::UnresolvedOperand> syms(symsRef.begin(),
symsRef.end());
SmallVector<OpAsmParser::UnresolvedOperand> syms(symsRef);
flatDimOperands.append(map.getValue().getNumResults(), dims);
flatSymOperands.append(map.getValue().getNumResults(), syms);
numMapsPerGroup.push_back(map.getValue().getNumResults());
Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,7 @@ unsigned mlir::affine::permuteLoops(MutableArrayRef<AffineForOp> input,
assert(input.size() == permMap.size() && "invalid permutation map size");
// Check whether the permutation spec is valid. This is a small vector - we'll
// just sort and check if it's iota.
SmallVector<unsigned, 4> checkPermMap(permMap.begin(), permMap.end());
SmallVector<unsigned, 4> checkPermMap(permMap);
llvm::sort(checkPermMap);
if (llvm::any_of(llvm::enumerate(checkPermMap),
[](const auto &en) { return en.value() != en.index(); }))
Expand Down Expand Up @@ -1583,7 +1583,7 @@ SmallVector<SmallVector<AffineForOp, 8>, 8>
mlir::affine::tile(ArrayRef<AffineForOp> forOps, ArrayRef<uint64_t> sizes,
ArrayRef<AffineForOp> targets) {
SmallVector<SmallVector<AffineForOp, 8>, 8> res;
SmallVector<AffineForOp, 8> currentTargets(targets.begin(), targets.end());
SmallVector<AffineForOp, 8> currentTargets(targets);
for (auto it : llvm::zip(forOps, sizes)) {
auto step = stripmineSink(std::get<0>(it), std::get<1>(it), currentTargets);
res.push_back(step);
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Arith/Transforms/IntNarrowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ struct NarrowingPattern : OpRewritePattern<SourceOp> {
NarrowingPattern(MLIRContext *ctx, const ArithIntNarrowingOptions &options,
PatternBenefit benefit = 1)
: OpRewritePattern<SourceOp>(ctx, benefit),
supportedBitwidths(options.bitwidthsSupported.begin(),
options.bitwidthsSupported.end()) {
supportedBitwidths(options.bitwidthsSupported) {
assert(!supportedBitwidths.empty() && "Invalid options");
assert(!llvm::is_contained(supportedBitwidths, 0) && "Invalid bitwidth");
llvm::sort(supportedBitwidths);
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/GPU/TransformOps/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ static GpuIdBuilderFnType common3DIdBuilderFn(int64_t multiplicity = 1) {
rewriter, loc, d0.floorDiv(multiplicity), {scaledIds[0]})
.get<Value>();
// In the 3-D mapping case, unscale the first dimension by the multiplicity.
SmallVector<int64_t> forallMappingSizeInOriginalBasis(
forallMappingSizes.begin(), forallMappingSizes.end());
SmallVector<int64_t> forallMappingSizeInOriginalBasis(forallMappingSizes);
forallMappingSizeInOriginalBasis[0] *= multiplicity;
return IdBuilderResult{
/*mappingIdOps=*/scaledIds,
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/GPU/Transforms/NVVMAttachTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DictionaryAttr NVVMAttachTarget::getFlags(OpBuilder &builder) const {
void NVVMAttachTarget::runOnOperation() {
OpBuilder builder(&getContext());
ArrayRef<std::string> libs(linkLibs);
SmallVector<StringRef> filesToLink(libs.begin(), libs.end());
SmallVector<StringRef> filesToLink(libs);
auto target = builder.getAttr<NVVMTargetAttr>(
optLevel, triple, chip, features, getFlags(builder),
filesToLink.empty() ? nullptr : builder.getStrArrayAttr(filesToLink));
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/GPU/Transforms/ROCDLAttachTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DictionaryAttr ROCDLAttachTarget::getFlags(OpBuilder &builder) const {
void ROCDLAttachTarget::runOnOperation() {
OpBuilder builder(&getContext());
ArrayRef<std::string> libs(linkLibs);
SmallVector<StringRef> filesToLink(libs.begin(), libs.end());
SmallVector<StringRef> filesToLink(libs);
auto target = builder.getAttr<ROCDLTargetAttr>(
optLevel, triple, chip, features, abiVersion, getFlags(builder),
filesToLink.empty() ? nullptr : builder.getStrArrayAttr(filesToLink));
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,8 @@ transform::InterchangeOp::applyToOne(transform::TransformRewriter &rewriter,
<< ") different from the number of loops in the target operation ("
<< numLoops << ")";
}
FailureOr<GenericOp> res =
interchangeGenericOp(rewriter, target,
SmallVector<unsigned>(interchangeVector.begin(),
interchangeVector.end()));
FailureOr<GenericOp> res = interchangeGenericOp(
rewriter, target, SmallVector<unsigned>(interchangeVector));
if (failed(res))
return emitDefiniteFailure() << "failed to apply";
results.push_back(res->getOperation());
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Linalg/Transforms/Interchange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ mlir::linalg::interchangeGenericOp(RewriterBase &rewriter, GenericOp genericOp,
ArrayRef<Attribute> itTypes = genericOp.getIteratorTypes().getValue();
SmallVector<Attribute> itTypesVector;
llvm::append_range(itTypesVector, itTypes);
SmallVector<int64_t> permutation(interchangeVector.begin(),
interchangeVector.end());
SmallVector<int64_t> permutation(interchangeVector);
applyPermutationToVector(itTypesVector, permutation);
genericOp.setIteratorTypesAttr(rewriter.getArrayAttr(itTypesVector));

Expand Down
4 changes: 2 additions & 2 deletions mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static SmallVector<Value> makeCanonicalAffineApplies(OpBuilder &b, Location loc,
auto dims = map.getNumDims();
for (auto e : map.getResults()) {
auto exprMap = AffineMap::get(dims, map.getNumSymbols(), e);
SmallVector<Value> operands(vals.begin(), vals.end());
SmallVector<Value> operands(vals);
affine::canonicalizeMapAndOperands(&exprMap, &operands);
res.push_back(b.create<affine::AffineApplyOp>(loc, exprMap, operands));
}
Expand Down Expand Up @@ -133,7 +133,7 @@ static void emitScalarImplementation(OpBuilder &b, Location loc,
SmallVector<Value> indexedValues;
indexedValues.reserve(linalgOp->getNumOperands());

auto allIvsPlusDims = SmallVector<Value>(allIvs.begin(), allIvs.end());
auto allIvsPlusDims = SmallVector<Value>(allIvs);

// TODO: Avoid the loads if the corresponding argument of the
// region has no uses.
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ mlir::linalg::makeTiledLoopRanges(RewriterBase &b, Location loc, AffineMap map,
// Apply `map` to get shape sizes in loop order.
SmallVector<OpFoldResult> shapeSizes =
makeComposedFoldedMultiResultAffineApply(b, loc, map, allShapeSizes);
SmallVector<OpFoldResult> tileSizes(allTileSizes.begin(), allTileSizes.end());
SmallVector<OpFoldResult> tileSizes(allTileSizes);

// Traverse the tile sizes, which are in loop order, erase zeros everywhere.
LoopIndexToRangeIndexMap loopIndexToRangeIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ struct LinalgOpPartialReductionInterface
Location loc, ValueRange partialReduce,
ArrayRef<int> reductionDims) const {
auto linalgOp = cast<LinalgOp>(op);
SmallVector<int64_t> reductionDimsInt64(reductionDims.begin(),
reductionDims.end());
SmallVector<int64_t> reductionDimsInt64(reductionDims);
auto reduction = b.create<linalg::ReduceOp>(
loc, partialReduce, linalgOp.getDpsInits(), reductionDimsInt64,
[&linalgOp](OpBuilder &b, Location loc, ValueRange inputs) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ linalg::packMatmulGreedily(RewriterBase &rewriter, LinalgOp linalgOp,
LinalgTilingOptions &
mlir::linalg::LinalgTilingOptions::setTileSizes(ArrayRef<int64_t> ts) {
assert(!tileSizeComputationFunction && "tile sizes already set");
SmallVector<int64_t, 4> tileSizes(ts.begin(), ts.end());
SmallVector<int64_t, 4> tileSizes(ts);
tileSizeComputationFunction = [tileSizes](OpBuilder &b, Operation *op) {
OpBuilder::InsertionGuard guard(b);
b.setInsertionPointToStart(
Expand Down
3 changes: 1 addition & 2 deletions mlir/lib/Dialect/Linalg/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,7 @@ GenericOp makeTransposeOp(OpBuilder &b, Location loc, Value inputTensor,
// Compute the transpose and the indentity indexing maps.
SmallVector<AffineMap> indexingMaps = {
inversePermutation(AffineMap::getPermutationMap(
SmallVector<unsigned>(transposeVector.begin(), transposeVector.end()),
b.getContext())),
SmallVector<unsigned>(transposeVector), b.getContext())),
AffineMap::getMultiDimIdentityMap(transposeVector.size(),
b.getContext())};
SmallVector<utils::IteratorType> iteratorTypes(transposeVector.size(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ handleMultidimensionalVectors(ImplicitLocOpBuilder &builder,

// Maybe expand operands to the higher rank vector shape that we'll use to
// iterate over and extract one dimensional vectors.
SmallVector<int64_t> expandedShape(inputShape.begin(), inputShape.end());
SmallVector<int64_t> expandedShape(inputShape);
SmallVector<Value> expandedOperands(operands);

if (expansionDim > 1) {
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ static void constifyIndexValues(
/// expected for `getAttributes` in `constifyIndexValues`.
static SmallVector<int64_t> getConstantSizes(MemRefType memRefTy) {
ArrayRef<int64_t> sizes = memRefTy.getShape();
return SmallVector<int64_t>(sizes.begin(), sizes.end());
return SmallVector<int64_t>(sizes);
}

/// Wrapper around `getStridesAndOffset` that returns only the offset and
Expand Down
10 changes: 5 additions & 5 deletions mlir/lib/Dialect/NVGPU/TransformOps/NVGPUTransformOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,9 +740,9 @@ static std::tuple<SmallVector<int64_t>, SmallVector<int64_t>,
SmallVector<int64_t>>
makeVectorShapes(ArrayRef<int64_t> lhs, ArrayRef<int64_t> rhs,
ArrayRef<int64_t> res) {
SmallVector<int64_t> vlhs{lhs.begin(), lhs.end()};
SmallVector<int64_t> vrhs{rhs.begin(), rhs.end()};
SmallVector<int64_t> vres{res.begin(), res.end()};
SmallVector<int64_t> vlhs{lhs};
SmallVector<int64_t> vrhs{rhs};
SmallVector<int64_t> vres{res};
return std::make_tuple(vlhs, vrhs, vres);
}

Expand All @@ -758,7 +758,7 @@ MmaSyncBuilder::getIndexCalculators(ArrayRef<int64_t> opShape,
&MmaSyncBuilder::m16n8k4tf32Rhs,
&MmaSyncBuilder::m16n8k4tf32Res),
makeVectorShapes({2, 1}, {1, 1}, {2, 2}),
SmallVector<int64_t>{opShape.begin(), opShape.end()},
SmallVector<int64_t>{opShape},
/*tf32Enabled=*/true};
}
// This is the version with f16 accumulation.
Expand All @@ -769,7 +769,7 @@ MmaSyncBuilder::getIndexCalculators(ArrayRef<int64_t> opShape,
&MmaSyncBuilder::m16n8k16f16Rhs,
&MmaSyncBuilder::m16n8k16f16Res),
makeVectorShapes({4, 2}, {2, 2}, {2, 2}),
SmallVector<int64_t>{opShape.begin(), opShape.end()},
SmallVector<int64_t>{opShape},
/*tf32Enabled=*/false};
}
return failure();
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SCF/Utils/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ SmallVector<Loops, 8> mlir::tile(ArrayRef<scf::ForOp> forOps,
ArrayRef<Value> sizes,
ArrayRef<scf::ForOp> targets) {
SmallVector<SmallVector<scf::ForOp, 8>, 8> res;
SmallVector<scf::ForOp, 8> currentTargets(targets.begin(), targets.end());
SmallVector<scf::ForOp, 8> currentTargets(targets);
for (auto it : llvm::zip(forOps, sizes)) {
auto step = stripmineSink(std::get<0>(it), std::get<1>(it), currentTargets);
res.push_back(step);
Expand Down
2 changes: 1 addition & 1 deletion mlir/lib/Dialect/SPIRV/IR/SPIRVTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ StructType::get(ArrayRef<Type> memberTypes,
assert(!memberTypes.empty() && "Struct needs at least one member type");
// Sort the decorations.
SmallVector<StructType::MemberDecorationInfo, 4> sortedDecorations(
memberDecorations.begin(), memberDecorations.end());
memberDecorations);
llvm::array_pod_sort(sortedDecorations.begin(), sortedDecorations.end());
return Base::get(memberTypes.vec().front().getContext(),
/*identifier=*/StringRef(), memberTypes, offsetInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ static void forEachIJPairInAllBuffers(
function_ref<void(uint64_t, Value, Value, Value)> bodyBuilder) {

// Create code for the first (xPerm + ny) buffers.
SmallVector<AffineExpr> exps(xPerm.getResults().begin(),
xPerm.getResults().end());
SmallVector<AffineExpr> exps(xPerm.getResults());
for (unsigned y = 0; y < ny; y++) {
exps.push_back(builder.getAffineDimExpr(y + xPerm.getNumResults()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static Value genVectorLoad(PatternRewriter &rewriter, Location loc, VL vl,
VectorType vtp = vectorType(vl, mem);
Value pass = constantZero(rewriter, loc, vtp);
if (llvm::isa<VectorType>(idxs.back().getType())) {
SmallVector<Value> scalarArgs(idxs.begin(), idxs.end());
SmallVector<Value> scalarArgs(idxs);
Value indexVec = idxs.back();
scalarArgs.back() = constantIndex(rewriter, loc, 0);
return rewriter.create<vector::GatherOp>(loc, vtp, mem, scalarArgs,
Expand All @@ -129,7 +129,7 @@ static Value genVectorLoad(PatternRewriter &rewriter, Location loc, VL vl,
static void genVectorStore(PatternRewriter &rewriter, Location loc, Value mem,
ArrayRef<Value> idxs, Value vmask, Value rhs) {
if (llvm::isa<VectorType>(idxs.back().getType())) {
SmallVector<Value> scalarArgs(idxs.begin(), idxs.end());
SmallVector<Value> scalarArgs(idxs);
Value indexVec = idxs.back();
scalarArgs.back() = constantIndex(rewriter, loc, 0);
rewriter.create<vector::ScatterOp>(loc, mem, scalarArgs, indexVec, vmask,
Expand Down
6 changes: 2 additions & 4 deletions mlir/lib/Dialect/Tensor/IR/TensorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ static llvm::SmallBitVector getDroppedDims(ArrayRef<int64_t> reducedShape,
static RankedTensorType
foldDynamicToStaticDimSizes(RankedTensorType type, ValueRange dynamicSizes,
SmallVector<Value> &foldedDynamicSizes) {
SmallVector<int64_t> staticShape(type.getShape().begin(),
type.getShape().end());
SmallVector<int64_t> staticShape(type.getShape());
assert(type.getNumDynamicDims() ==
static_cast<int64_t>(dynamicSizes.size()) &&
"incorrect number of dynamic sizes");
Expand Down Expand Up @@ -2810,8 +2809,7 @@ struct InsertSliceOpSourceCastInserter final
RankedTensorType srcType = insertSliceOp.getSourceType();
if (srcType.getRank() != insertSliceOp.getDestType().getRank())
return failure();
SmallVector<int64_t> newSrcShape(srcType.getShape().begin(),
srcType.getShape().end());
SmallVector<int64_t> newSrcShape(srcType.getShape());
for (int64_t i = 0; i < srcType.getRank(); ++i) {
if (std::optional<int64_t> constInt =
getConstantIntValue(insertSliceOp.getMixedSizes()[i])) {
Expand Down
9 changes: 4 additions & 5 deletions mlir/lib/Dialect/Tensor/IR/TensorTilingInterfaceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ struct PackOpTiling
// The tiling is applied on interchanged dimensions. We have to undo the
// interchange to map sizes and offsets to the original input.
int64_t inputRank = packOp.getSourceRank();
SmallVector<OpFoldResult> origOffsets(offsets.begin(), offsets.end());
SmallVector<OpFoldResult> origSizes(sizes.begin(), sizes.end());
SmallVector<OpFoldResult> origOffsets(offsets);
SmallVector<OpFoldResult> origSizes(sizes);
applyPermToRange(origOffsets, origSizes,
invertPermutationVector(packOp.getOuterDimsPerm()));

Expand Down Expand Up @@ -486,9 +486,8 @@ struct UnPackOpTiling
// The tiling is applied on interchanged dimensions. We have to undo the
// interchange to map sizes and offsets to the original input.
int64_t outputRank = unPackOp.getDestRank();
SmallVector<OpFoldResult> origOffsets(destOffsets.begin(),
destOffsets.end());
SmallVector<OpFoldResult> origSizes(destSizes.begin(), destSizes.end());
SmallVector<OpFoldResult> origOffsets(destOffsets);
SmallVector<OpFoldResult> origSizes(destSizes);
applyPermToRange(origOffsets, origSizes,
invertPermutationVector(unPackOp.getOuterDimsPerm()));

Expand Down
Loading
Loading