cutlass icon indicating copy to clipboard operation
cutlass copied to clipboard

[QST] why have Int<2>{} in coalesce_x function when last shape value equal to constant one.

Open Shan19900305 opened this issue 11 months ago • 2 comments

In function coalesce_x, shape value is using default Int<2>{} when last shape value equal to constant one. Why need to do this?

` template <class Shape, class Stride> CUTE_HOST_DEVICE constexpr auto coalesce_x(Layout<Shape,Stride> const& layout) { auto flat_shape = flatten(layout.shape()); auto flat_stride = flatten(layout.stride());

constexpr int R = decltype(rank(flat_shape))::value; if constexpr (is_constant<1, decltype(get<R-1>(flat_shape))>::value) { return detail::bw_coalesce<R-2>(flat_shape, flat_stride, Int<2>{}, get<R-1>(flat_stride)); } else { return detail::bw_coalesce<R-2>(flat_shape, flat_stride, get<R-1>(flat_shape), get<R-1>(flat_stride)); } } `

Shan19900305 avatar Jan 05 '25 16:01 Shan19900305

It is an implementation detail that fixes cases like

(4,1):(1,42) o 12:1 => (4,3):(1,42)

to obey the composition definition

(A o B)(c) = A(B(c))

even when B(c) is "out-of-bounds" of A while also wanting to coalesce A before computing the result.

ccecka avatar Jan 05 '25 22:01 ccecka

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

github-actions[bot] avatar Feb 04 '25 23:02 github-actions[bot]