@@ -413,7 +413,7 @@ CGAEncodingAttr CGAEncodingAttr::getDefault(MLIRContext *ctx, int rank) {
413413 LinearLayout::BasesT bases;
414414 bases[kBlock ] = {};
415415 auto dims = standardOutDimNames (ctx, rank);
416- return get (ctx, LinearLayout (bases, dims));
416+ return get (ctx, LinearLayout (std::move ( bases) , dims));
417417}
418418
419419CGAEncodingAttr CGAEncodingAttr::fromSplitParams (MLIRContext *ctx,
@@ -438,18 +438,18 @@ CGAEncodingAttr CGAEncodingAttr::fromSplitParams(MLIRContext *ctx,
438438 }
439439
440440 layout = layout.transposeOuts (outDimNames);
441- return CGAEncodingAttr::get (ctx, layout);
441+ return CGAEncodingAttr::get (ctx, std::move ( layout) );
442442}
443443
444444SmallVector<unsigned > CGAEncodingAttr::getCTAsPerCGA () const {
445- auto ll = getLinearLayout ();
445+ const auto & ll = getLinearLayout ();
446446 auto rank = ll.getNumOutDims ();
447447 return basesPerDimImpl (ll.getBases (), StringAttr::get (getContext (), " block" ),
448448 rank, /* skipBroadcast=*/ false );
449449}
450450
451451SmallVector<unsigned > CGAEncodingAttr::getCTASplitNum () const {
452- auto ll = getLinearLayout ();
452+ const auto & ll = getLinearLayout ();
453453 auto rank = ll.getNumOutDims ();
454454 return basesPerDimImpl (ll.getBases (), StringAttr::get (getContext (), " block" ),
455455 rank);
@@ -996,7 +996,7 @@ basesPerDimImpl(const LinearLayout::BasesT &namedBases, StringAttr dimName,
996996
997997SmallVector<unsigned >
998998LinearEncodingAttr::basesPerDim (StringAttr dimName, bool skipBroadcast) const {
999- auto ll = getLinearLayout ();
999+ const auto & ll = getLinearLayout ();
10001000 auto rank = ll.getNumOutDims ();
10011001 return basesPerDimImpl (ll.getBases (), dimName, rank, skipBroadcast);
10021002}
@@ -1066,7 +1066,7 @@ SmallVector<unsigned> LinearEncodingAttr::getThreadOrder() const {
10661066
10671067SmallVector<unsigned > LinearEncodingAttr::getSizePerThread () const {
10681068 auto rank = getOrder ().size ();
1069- auto ll = getLinearLayout ();
1069+ const auto & ll = getLinearLayout ();
10701070 auto ctx = getContext ();
10711071 auto kRegister = StringAttr::get (ctx, " register" );
10721072 auto splitNum = getCGALayout ().getCTASplitNum ();
@@ -1144,7 +1144,7 @@ LinearEncodingAttr::getElemsPerThread(ArrayRef<int64_t> shape) const {
11441144SmallVector<unsigned >
11451145LinearEncodingAttr::getContig (const char *inDim,
11461146 SmallVector<unsigned int > lowerContig) const {
1147- auto ll = getLinearLayout ();
1147+ const auto & ll = getLinearLayout ();
11481148 const auto &bases =
11491149 ll.getBases ().find (StringAttr::get (getContext (), inDim))->second ;
11501150 auto order = getOrder ();
@@ -1517,7 +1517,7 @@ SmallVector<unsigned> SliceEncodingAttr::getRepOrder() const {
15171517CGAEncodingAttr SliceEncodingAttr::getCGALayout () const {
15181518 auto layout = ::getCGALayout (getParent ()).getLinearLayout ();
15191519 layout = removeStandardDim (layout, getDim ());
1520- return CGAEncodingAttr::get (getContext (), layout);
1520+ return CGAEncodingAttr::get (getContext (), std::move ( layout) );
15211521}
15221522
15231523template <class T >
@@ -1749,7 +1749,7 @@ Attribute SharedLinearEncodingAttr::parse(AsmParser &parser, Type type) {
17491749SmallVector<unsigned >
17501750SharedLinearEncodingAttr::basesPerDim (StringAttr dimName,
17511751 bool skipBroadcast) const {
1752- auto ll = getLinearLayout ();
1752+ const auto & ll = getLinearLayout ();
17531753 auto rank = ll.getNumOutDims ();
17541754 return basesPerDimImpl (ll.getBases (), dimName, rank, skipBroadcast);
17551755}
@@ -1761,7 +1761,7 @@ SharedLinearEncodingAttr::orderPerDim(StringAttr dimName,
17611761}
17621762
17631763SmallVector<unsigned > SharedLinearEncodingAttr::getOrder () const {
1764- auto ll = getLinearLayout ();
1764+ const auto & ll = getLinearLayout ();
17651765 auto rank = ll.getNumOutDims ();
17661766 SmallVector<unsigned > defaultOrder (rank);
17671767 std::iota (defaultOrder.rbegin (), defaultOrder.rend (), 0 );
@@ -1774,7 +1774,7 @@ CGAEncodingAttr SharedLinearEncodingAttr::getCGALayout() const {
17741774}
17751775LinearLayout
17761776SharedLinearEncodingAttr::toLinearLayout (ArrayRef<int64_t > shape) const {
1777- auto ll = getLinearLayout ();
1777+ const auto & ll = getLinearLayout ();
17781778 auto outDimNames = llvm::to_vector (ll.getOutDimNames ());
17791779 assert (shape.size () == outDimNames.size ());
17801780 // We don't support automatic broadcasting for shared linear layouts
@@ -1997,7 +1997,7 @@ PaddedSharedEncodingAttr PaddedSharedEncodingAttr::get(
19971997 identityStandardND (kOffset , SmallVector<unsigned >(shape), order);
19981998 linearComponent = combineCtaCgaWithShape (linearComponent, cgaLayout, shape);
19991999
2000- return get (context, intervalPads, linearComponent);
2000+ return get (context, intervalPads, std::move ( linearComponent) );
20012001}
20022002
20032003PaddedSharedEncodingAttr PaddedSharedEncodingAttr::get (
@@ -2010,7 +2010,7 @@ PaddedSharedEncodingAttr PaddedSharedEncodingAttr::get(
20102010 intervals.push_back (interval);
20112011 paddings.push_back (padding);
20122012 }
2013- return get (context, intervals, paddings, linearComponent);
2013+ return get (context, intervals, paddings, std::move ( linearComponent) );
20142014}
20152015
20162016SmallVector<unsigned >
@@ -2454,7 +2454,7 @@ SmallVector<unsigned> DotOperandEncodingAttr::getRepOrder() const {
24542454}
24552455
24562456CGAEncodingAttr DotOperandEncodingAttr::getCGALayout () const {
2457- auto layout = ::getCGALayout (getParent ()).getLinearLayout ();
2457+ const auto & layout = ::getCGALayout (getParent ()).getLinearLayout ();
24582458 auto bases = layout.getBases ();
24592459 auto kBlock = StringAttr::get (getContext (), " block" );
24602460 auto &blockBases = bases[kBlock ];
@@ -2465,7 +2465,8 @@ CGAEncodingAttr DotOperandEncodingAttr::getCGALayout() const {
24652465 }
24662466 auto dims = layout.getOutDims ();
24672467 dims[kDim ].second = 1 ;
2468- return CGAEncodingAttr::get (getContext (), LinearLayout (bases, dims, true ));
2468+ return CGAEncodingAttr::get (getContext (),
2469+ LinearLayout (std::move (bases), dims, true ));
24692470}
24702471LogicalResult DotOperandEncodingAttr::verify (
24712472 ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
@@ -3071,7 +3072,7 @@ struct TritonGPUInferLayoutInterface
30713072 LinearLayout ll =
30723073 inferReshapeLinearLayout (cast<TensorOrMemDesc>(srcTy), dstShape);
30733074
3074- dstEnc = LinearEncodingAttr::get (srcEnc.getContext (), ll );
3075+ dstEnc = LinearEncodingAttr::get (srcEnc.getContext (), std::move (ll) );
30753076 return success ();
30763077 }
30773078
@@ -3119,7 +3120,7 @@ struct TritonGPUInferLayoutInterface
31193120 enc.getContext (), append (enc.getSizePerThread (), 2 ),
31203121 append (enc.getThreadsPerWarp (), 1 ), append (enc.getWarpsPerCTA (), 1 ),
31213122 appendMajorDim (enc.getOrder ()),
3122- CGAEncodingAttr::get (enc.getContext (), ctall));
3123+ CGAEncodingAttr::get (enc.getContext (), std::move ( ctall) ));
31233124 return success ();
31243125 }
31253126
@@ -3136,7 +3137,7 @@ struct TritonGPUInferLayoutInterface
31363137 tryJoinOnAxis (ctx, ll, newLl, /* fwdInference=*/ true , axis, loc);
31373138
31383139 assert (result.succeeded ());
3139- dstEnc = LinearEncodingAttr::get (ctx, newLl);
3140+ dstEnc = LinearEncodingAttr::get (ctx, std::move ( newLl) );
31403141 return success ();
31413142 }
31423143
@@ -3167,7 +3168,7 @@ struct TritonGPUInferLayoutInterface
31673168 ArrayRef (enc.getSizePerThread ()).drop_back (1 ),
31683169 ArrayRef (enc.getThreadsPerWarp ()).drop_back (1 ),
31693170 ArrayRef (enc.getWarpsPerCTA ()).drop_back (1 ), ArrayRef (newOrder),
3170- CGAEncodingAttr::get (enc.getContext (), ctall));
3171+ CGAEncodingAttr::get (enc.getContext (), std::move ( ctall) ));
31713172 return success ();
31723173 }
31733174
@@ -3191,7 +3192,7 @@ struct TritonGPUInferLayoutInterface
31913192 SmallVector<int64_t > dstShape (shape.begin (), shape.end ());
31923193 dstShape.pop_back ();
31933194 newLl = newLl.reshapeOuts (standardOutDimPairs (ctx, dstShape));
3194- dstEnc = LinearEncodingAttr::get (ctx, newLl);
3195+ dstEnc = LinearEncodingAttr::get (ctx, std::move ( newLl) );
31953196 return success ();
31963197 }
31973198
@@ -3254,7 +3255,7 @@ struct TritonGPUInferLayoutInterface
32543255 auto result = tryJoinOnAxis (ctx, ll, newLl, fwdInference, axis, loc);
32553256 if (!result.succeeded ())
32563257 return result;
3257- outEnc = LinearEncodingAttr::get (ctx, newLl);
3258+ outEnc = LinearEncodingAttr::get (ctx, std::move ( newLl) );
32583259 return success ();
32593260 }
32603261};
0 commit comments