CUTLASS 3.5.0 (#1411)
This commit is contained in:
@@ -81,7 +81,7 @@ struct Copy_Atom<Copy_Traits<Args...>, CopyInternalType>
|
||||
CUTE_HOST_DEVICE
|
||||
auto
|
||||
with(TraitsArgs&&... args) const {
|
||||
auto traits = Traits::with(std::forward<TraitsArgs>(args)...);
|
||||
auto traits = Traits::with(static_cast<TraitsArgs&&>(args)...);
|
||||
return Copy_Atom<decltype(traits), CopyInternalType>{traits};
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ struct ThrCopy
|
||||
partition_S(STensor&& stensor) const {
|
||||
//static_assert(sizeof(typename remove_cvref_t<STensor>::value_type) == sizeof(typename TiledCopy::ValType),
|
||||
// "Expected ValType for tiling SrcTensor.");
|
||||
auto thr_tensor = make_tensor(std::forward<STensor>(stensor).data(), TiledCopy::tidfrg_S(stensor.layout()));
|
||||
auto thr_tensor = make_tensor(static_cast<STensor&&>(stensor).data(), TiledCopy::tidfrg_S(stensor.layout()));
|
||||
return thr_tensor(thr_idx_, _, repeat<rank_v<STensor>>(_));
|
||||
}
|
||||
|
||||
@@ -361,7 +361,7 @@ struct ThrCopy
|
||||
partition_D(DTensor&& dtensor) const {
|
||||
//static_assert(sizeof(typename remove_cvref_t<DTensor>::value_type) == sizeof(typename TiledCopy::ValType),
|
||||
// "Expected ValType for tiling DstTensor.");
|
||||
auto thr_tensor = make_tensor(std::forward<DTensor>(dtensor).data(), TiledCopy::tidfrg_D(dtensor.layout()));
|
||||
auto thr_tensor = make_tensor(static_cast<DTensor&&>(dtensor).data(), TiledCopy::tidfrg_D(dtensor.layout()));
|
||||
return thr_tensor(thr_idx_, _, repeat<rank_v<DTensor>>(_));
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ struct ThrCopy
|
||||
retile_S(STensor&& stensor) {
|
||||
// static_assert(sizeof(typename remove_cvref_t<STensor>::value_type) == sizeof(typename TiledCopy::ValType),
|
||||
// "Expected ValType for tiling SrcTensor.");
|
||||
return make_tensor(std::forward<STensor>(stensor).data(), TiledCopy::retile(stensor.layout()));
|
||||
return make_tensor(static_cast<STensor&&>(stensor).data(), TiledCopy::retile(stensor.layout()));
|
||||
}
|
||||
|
||||
template <class DTensor>
|
||||
@@ -380,7 +380,7 @@ struct ThrCopy
|
||||
retile_D(DTensor&& dtensor) {
|
||||
// static_assert(sizeof(typename remove_cvref_t<DTensor>::value_type) == sizeof(typename TiledCopy::ValType),
|
||||
// "Expected ValType for tiling DstTensor.");
|
||||
return make_tensor(std::forward<DTensor>(dtensor).data(), TiledCopy::retile(dtensor.layout()));
|
||||
return make_tensor(static_cast<DTensor&&>(dtensor).data(), TiledCopy::retile(dtensor.layout()));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -94,17 +94,55 @@ struct Copy_Traits<AutoVectorizingCopyWithAssumedAlignment<MaxVecBits>>
|
||||
|
||||
namespace detail {
|
||||
|
||||
// Utility for exploding pointers, arrays, or tensors into Operation::copy
|
||||
template <class Operation,
|
||||
class PtrS, int... Is,
|
||||
class PtrD, int... Id>
|
||||
class PtrSrc, int... Is,
|
||||
class PtrDst, int... Id>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_explode(PtrS&& s, int_sequence<Is...>,
|
||||
PtrD&& d, int_sequence<Id...>)
|
||||
copy_explode_index(PtrSrc&& s, int_sequence<Is...>,
|
||||
PtrDst&& d, int_sequence<Id...>)
|
||||
{
|
||||
return Operation::copy(s[Is]..., d[Id]...);
|
||||
}
|
||||
|
||||
// Utility for exploding tuples into ::copy
|
||||
template <class Operation,
|
||||
class TupleArg, int... I>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_explode(TupleArg&& t, int_sequence<I...>)
|
||||
{
|
||||
return Operation::copy(get<I>(static_cast<TupleArg&&>(t))...);
|
||||
}
|
||||
|
||||
template <class Operation,
|
||||
class TupleSrc, int... Is,
|
||||
class TupleDst, int... Id>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_explode(TupleSrc&& s, int_sequence<Is...>,
|
||||
TupleDst&& d, int_sequence<Id...>)
|
||||
{
|
||||
return Operation::copy(get<Is>(static_cast<TupleSrc&&>(s))...,
|
||||
get<Id>(static_cast<TupleDst&&>(d))...);
|
||||
}
|
||||
|
||||
template <class Operation,
|
||||
class TupleAux, int... Ia,
|
||||
class TupleSrc, int... Is,
|
||||
class TupleDst, int... Id>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_explode(TupleAux&& a, int_sequence<Ia...>,
|
||||
TupleSrc&& s, int_sequence<Is...>,
|
||||
TupleDst&& d, int_sequence<Id...>)
|
||||
{
|
||||
return Operation::copy(get<Ia>(static_cast<TupleAux&&>(a))...,
|
||||
get<Is>(static_cast<TupleSrc&&>(s))...,
|
||||
get<Id>(static_cast<TupleDst&&>(d))...);
|
||||
}
|
||||
|
||||
} // end namespace detail
|
||||
|
||||
//
|
||||
@@ -139,8 +177,8 @@ copy_unpack(Copy_Traits<CopyOp,Args...> const&,
|
||||
CUTE_STATIC_ASSERT_V(size(rD) == Int<RegNumDst>{},
|
||||
"Copy_Traits: dst failed to vectorize into registers. Layout is incompatible with this CopyOp.");
|
||||
|
||||
detail::copy_explode<CopyOp>(rS, make_int_sequence<RegNumSrc>{},
|
||||
rD, make_int_sequence<RegNumDst>{});
|
||||
detail::copy_explode_index<CopyOp>(rS, make_int_sequence<RegNumSrc>{},
|
||||
rD, make_int_sequence<RegNumDst>{});
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -0,0 +1,879 @@
|
||||
/***************************************************************************************************
|
||||
* Copyright (c) 2023 - 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
#pragma once
|
||||
|
||||
/*! \file
|
||||
\brief im2col make_tma_copy
|
||||
*/
|
||||
|
||||
#include "cute/arch/copy_sm90.hpp"
|
||||
#include "cute/arch/copy_sm90_desc.hpp"
|
||||
#include "cute/tensor.hpp"
|
||||
|
||||
#include "cute/algorithm/prefetch.hpp"
|
||||
|
||||
namespace cute
|
||||
{
|
||||
|
||||
// Utility for unpacking TMA_LOAD_IM2COL arguments into a CopyOp
|
||||
template <class CopyOp>
|
||||
struct TMA_LOAD_IM2COL_Unpack
|
||||
{
|
||||
/// Copy from src to dst.
|
||||
///
|
||||
/// @param traits Copy traits created with a TMA descriptor that
|
||||
/// correctly matches the input tensor and other convolution
|
||||
/// parameters.
|
||||
///
|
||||
/// @param src Tile of the im2col-transformed coordinate tensor
|
||||
/// (result of get_tma_tensor), representing the global-memory
|
||||
/// tensor from which to load.
|
||||
///
|
||||
/// @param dst Shared memory tile, into which to load.
|
||||
template <class... Args,
|
||||
class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits<CopyOp, Args...> const& traits,
|
||||
Tensor<TS,SLayout> const& src, // tile of the transformed global activation (A) tensor
|
||||
Tensor<TD,DLayout> & dst) // shared memory tile
|
||||
{
|
||||
auto src_coord_offset = src(Int<0>{});
|
||||
auto src_coord_cwhdn_offset_srt = flatten(src_coord_offset);
|
||||
// Interpret the TMA IM2COL coordinate as (c, ([w,h,d]), n, ([s,r,t]))
|
||||
CUTE_STATIC_ASSERT_V(rank(src_coord_offset) == _4{});
|
||||
CUTE_STATIC_ASSERT_V(rank<1>(src_coord_offset) == rank<3>(src_coord_offset));
|
||||
|
||||
if constexpr (detail::is_prefetch<CopyOp>) {
|
||||
return detail::copy_explode<CopyOp>(traits.opargs_, tuple_seq<decltype(traits.opargs_)>{},
|
||||
src_coord_cwhdn_offset_srt, tuple_seq<decltype(src_coord_cwhdn_offset_srt)>{});
|
||||
} else {
|
||||
static_assert(is_smem<TD>::value, "SM90_TMA_LOAD_IM2COL requires the destination be shared memory.");
|
||||
void* dst_ptr = cute::raw_pointer_cast(dst.data());
|
||||
return detail::copy_explode<CopyOp>(traits.opargs_, tuple_seq<decltype(traits.opargs_)>{},
|
||||
make_tuple(dst_ptr), seq<0>{},
|
||||
src_coord_cwhdn_offset_srt, tuple_seq<decltype(src_coord_cwhdn_offset_srt)>{});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Copy_Traits for SM90 im2col TMA load comes in two layers.
|
||||
//
|
||||
// 1. Copy_Traits<SM90_TMA_LOAD_IM2COL>
|
||||
// 2. Copy_Traits<SM90_TMA_LOAD_IM2COL_OP>
|
||||
//
|
||||
// Copy_Traits<SM90_TMA_LOAD_IM2COL>
|
||||
// is the "outer" layer. It has a TMA descriptor,
|
||||
// but no barrier ("tma_mbar"), so it's "nonexecutable."
|
||||
// One calls its "with" member function with a barrier,
|
||||
// to get an executable "inner"-layer
|
||||
// Copy_Traits<SM90_TMA_LOAD_IM2COL_OP> object.
|
||||
// That object's "copy_unpack" member function
|
||||
// actually invokes im2col TMA load.
|
||||
|
||||
struct SM90_TMA_LOAD_IM2COL_OP : SM90_TMA_LOAD_IM2COL {};
|
||||
|
||||
/// @brief Non-executable specialization of Copy_Traits for SM90
|
||||
/// im2col TMA load, with TMA descriptor but no barrier.
|
||||
///
|
||||
/// Use `.with(memory_barrier)` to construct an executable version.
|
||||
template <class NumBitsPerTMA, class TMATensor>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_IM2COL, NumBitsPerTMA, TMATensor>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
Im2ColTmaDescriptor tma_desc_;
|
||||
TMATensor tma_tensor_;
|
||||
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Im2ColTmaDescriptor const*
|
||||
get_tma_descriptor() const
|
||||
{
|
||||
return &tma_desc_;
|
||||
}
|
||||
|
||||
template <class GShape>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
TMATensor const
|
||||
get_tma_tensor(GShape const&) const
|
||||
{
|
||||
return tma_tensor_;
|
||||
}
|
||||
|
||||
/// @brief Get an executable specialization.
|
||||
///
|
||||
/// Copy_Traits specializations with SM90_TMA_LOAD_IM2COL are not
|
||||
/// directly executable. Instead, call this "with" member function
|
||||
/// to get an executable specialization. "Executable" means that
|
||||
/// @c copy_unpack works.
|
||||
///
|
||||
/// @param tma_mbar Memory barrier for synchronization
|
||||
///
|
||||
/// @param multicast_mask Multicast mask (unused; only exists
|
||||
/// for interface compatibility with the actual multicast Copy_Traits)
|
||||
///
|
||||
/// @return Executable specialization of @c Copy_Traits
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_TMA_LOAD_IM2COL_OP, NumBitsPerTMA>
|
||||
with(uint64_t& tma_mbar, [[maybe_unused]] uint16_t const& multicast_mask = 0) const
|
||||
{
|
||||
return {{}, {&tma_desc_, &tma_mbar}};
|
||||
}
|
||||
|
||||
// Copy_Traits specializations with SM90_TMA_LOAD_IM2COL
|
||||
// are not directly executable. Instead, call .with
|
||||
// to get an executable specialization.
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst) = delete;
|
||||
};
|
||||
|
||||
/// @brief Executable specialization of Copy_Traits for SM90 im2col
|
||||
/// TMA load, with TMA descriptor and barrier.
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_IM2COL_OP, NumBitsPerTMA>
|
||||
: TMA_LOAD_IM2COL_Unpack<SM90_TMA_LOAD_IM2COL_OP>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD_IM2COL arguments
|
||||
tuple<
|
||||
Im2ColTmaDescriptor const*,
|
||||
uint64_t* // smem mbarrier
|
||||
> const opargs_;
|
||||
};
|
||||
|
||||
template <class NumBitsPerTMA, class... Args>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_IM2COL::PREFETCH, NumBitsPerTMA, Args...>
|
||||
: TMA_LOAD_IM2COL_Unpack<SM90_TMA_LOAD_IM2COL::PREFETCH>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD_IM2COL::PREFETCH arguments
|
||||
tuple<Im2ColTmaDescriptor const*> const opargs_;
|
||||
|
||||
CUTE_HOST_DEVICE
|
||||
Copy_Traits(Copy_Traits<SM90_TMA_LOAD_IM2COL, NumBitsPerTMA, Args...> const& traits)
|
||||
: opargs_({&traits.tma_desc_}) {}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_LOAD_MULTICAST /////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SM90_TMA_LOAD_IM2COL_MULTICAST_OP : SM90_TMA_LOAD_IM2COL_MULTICAST {};
|
||||
|
||||
/// @brief Non-executable specialization of Copy_Traits for SM90
|
||||
/// im2col TMA load, with TMA descriptor but no barrier or multicast
|
||||
/// mask.
|
||||
///
|
||||
/// Use `.with(memory_barrier)` to construct an executable version.
|
||||
template <class NumBitsPerTMA, class TMATensor>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_IM2COL_MULTICAST, NumBitsPerTMA, TMATensor>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
Im2ColTmaDescriptor tma_desc_;
|
||||
TMATensor tma_tensor_;
|
||||
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Im2ColTmaDescriptor const*
|
||||
get_tma_descriptor() const {
|
||||
return &tma_desc_;
|
||||
}
|
||||
|
||||
template <class GShape>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
TMATensor const
|
||||
get_tma_tensor(GShape const&) const
|
||||
{
|
||||
return tma_tensor_;
|
||||
}
|
||||
|
||||
/// @brief Get an executable specialization.
|
||||
///
|
||||
/// Copy_Traits specializations with SM90_TMA_LOAD_IM2COL_MULTICAST
|
||||
/// are not directly executable. Instead, call this "with" member
|
||||
/// function to get an executable specialization. "Executable"
|
||||
/// means that @c copy_unpack works.
|
||||
///
|
||||
/// @param tma_mbar Memory barrier for synchronization
|
||||
///
|
||||
/// @param multicast_mask Multicast mask (defaults to a single CTA)
|
||||
///
|
||||
/// @return Executable specialization of @c Copy_Traits
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_TMA_LOAD_IM2COL_MULTICAST_OP, NumBitsPerTMA>
|
||||
with(uint64_t& tma_mbar, uint16_t const& multicast_mask) const {
|
||||
return {{}, {&tma_desc_, &tma_mbar, multicast_mask}};
|
||||
}
|
||||
|
||||
// Copy_Traits specializations with SM90_TMA_LOAD_IM2COL_MULTICAST
|
||||
// are not directly executable. Instead, call .with to get an
|
||||
// executable specialization.
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst) = delete;
|
||||
};
|
||||
|
||||
/// @brief Executable specialization of Copy_Traits for SM90 multicast
|
||||
/// im2col TMA load, with TMA descriptor, barrier, and multicast mask.
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_IM2COL_MULTICAST_OP, NumBitsPerTMA>
|
||||
: TMA_LOAD_IM2COL_Unpack<SM90_TMA_LOAD_IM2COL_MULTICAST_OP>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit.
|
||||
using SrcLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1, NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD_IM2COL_MULTICAST arguments
|
||||
tuple<
|
||||
Im2ColTmaDescriptor const*,
|
||||
uint64_t*, // smem mbarrier
|
||||
uint16_t // multicast mask
|
||||
> const opargs_;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_STORE IM2COL////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// The executable SM90_TMA_STORE_IM2COL with tma_desc
|
||||
template <class NumBitsPerTMA, class TMATensor>
|
||||
struct Copy_Traits<SM90_TMA_STORE_IM2COL, NumBitsPerTMA, TMATensor>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_STORE_IM2COL arguments
|
||||
Im2ColTmaDescriptor tma_desc_;
|
||||
TMATensor tma_tensor_;
|
||||
|
||||
// Return TmaDescriptor/TensorMap
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Im2ColTmaDescriptor const*
|
||||
get_tma_descriptor() const {
|
||||
return &tma_desc_;
|
||||
}
|
||||
|
||||
template <class GShape>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
TMATensor const
|
||||
get_tma_tensor(GShape const&) const
|
||||
{
|
||||
return tma_tensor_;
|
||||
}
|
||||
|
||||
// This is the copy_unpack dispatch for this Copy_Traits
|
||||
// Src needs to be a smem tensor
|
||||
// Dst needs to be a gmem tensor with TmaCoordIterator .data()
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_smem<TS>::value, "Expected smem src for SM90_TMA_STORE_IM2COL");
|
||||
|
||||
void const* const desc_ptr = &(traits.tma_desc_);
|
||||
void const* const src_ptr = cute::raw_pointer_cast(src.data());
|
||||
auto dst_coord = flatten(take<0,3>(dst(Int<0>{})));
|
||||
|
||||
return detail::copy_explode<SM90_TMA_STORE_IM2COL>(make_tuple(desc_ptr, src_ptr), seq<0,1>{},
|
||||
dst_coord, tuple_seq<decltype(dst_coord)>{});
|
||||
}
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
/// @brief Creates a TMA descriptor for im2col TMA load.
|
||||
///
|
||||
/// @param tensor_cwhdn Global activation tensor (A matrix of Fprop).
|
||||
/// This is the original (not im2col-transformed) tensor in global
|
||||
/// memory.
|
||||
///
|
||||
/// @param slayout Rank 2 (M,K) shared memory layout of the activation
|
||||
/// tensor. Here, K is "GEMM K," not the filter tensor's mode of
|
||||
/// the same name.
|
||||
//////
|
||||
/// @param traversal_stride Traversal strides convolution parameter
|
||||
//////
|
||||
/// Each of padding_shape, traversal_stride, and dilation_shape is a
|
||||
/// tuple whose size is the number of spatial modes (e.g., 3 for a 5-D
|
||||
/// convolution).
|
||||
///
|
||||
/// @return TMA descriptor for im2col TMA load
|
||||
template <class EngineA, class LayoutA,
|
||||
class SmemSwizzle, class TMALayout,
|
||||
class LowerCornerStride,
|
||||
class UpperCornerStride,
|
||||
class LowerPaddingStride,
|
||||
class UpperPaddingStride,
|
||||
class TraversalStride,
|
||||
class LowerSRTStride,
|
||||
class DilationStride>
|
||||
CUTE_HOST
|
||||
auto
|
||||
make_im2col_tma_copy_desc(
|
||||
Tensor<EngineA, LayoutA> const& tensor_cwhdn, // (C,W,H,D,N)
|
||||
uint32_t range_c, // TILE_C
|
||||
uint32_t range_whdn, // TILE_WHDN
|
||||
SmemSwizzle const& smem_swizzle, // Swizzle
|
||||
TMALayout const& tma_layout_vt, // TMA layout
|
||||
LowerCornerStride const& lower_corner_whd, // WHD offset of the "base pointer"
|
||||
UpperCornerStride const& upper_corner_whd, // WHD upper corner
|
||||
LowerPaddingStride const& lower_padding_whd, // WHD lower padding
|
||||
UpperPaddingStride const& upper_padding_whd, // WHD upper padding
|
||||
TraversalStride const& stride_whd, // WHD traversal stride
|
||||
LowerSRTStride const& lower_srt, // SRT offset of the "base pointer"
|
||||
DilationStride const& stride_srt) // SRT stride - dilation
|
||||
{
|
||||
static_assert(is_gmem<EngineA>::value, "Tensor must point to GPU global memory.");
|
||||
using value_type = typename EngineA::value_type;
|
||||
|
||||
constexpr uint32_t num_total_modes = LayoutA::rank;
|
||||
constexpr int num_spatial_modes = num_total_modes - 2;
|
||||
|
||||
// Gmem starting address
|
||||
void* gmem_address = (void*) raw_pointer_cast(tensor_cwhdn.data());
|
||||
|
||||
// Gmem extents are just the tensor shape
|
||||
cute::array<uint64_t, 5> gmem_prob_shape = {1,1,1,1,1};
|
||||
for_each(make_seq<num_total_modes>{}, [&](auto i) {
|
||||
gmem_prob_shape[i] = static_cast<uint64_t>(shape<i>(tensor_cwhdn));
|
||||
});
|
||||
|
||||
// Gmem strides are byte strides of the activation tensor in CWHDN order
|
||||
cute::array<uint64_t, 5> gmem_prob_stride = {0,0,0,0,0};
|
||||
for_each(make_seq<num_total_modes>{}, [&](auto i) {
|
||||
gmem_prob_stride[i] = sizeof(value_type) * stride<i>(tensor_cwhdn);
|
||||
});
|
||||
|
||||
// Traversal strides are a function of the dilation shape
|
||||
// corresponding to spatial (WHD) modes.
|
||||
cute::array<uint32_t, 5> tma_traversal_strides = {1,1,1,1,1};
|
||||
for_each(make_seq<num_spatial_modes>{}, [&](auto i) {
|
||||
tma_traversal_strides[i+1] = static_cast<uint32_t>(get<i>(stride_whd));
|
||||
});
|
||||
|
||||
cute::array<int32_t, num_spatial_modes> tma_lower_corner{};
|
||||
for_each(make_seq<num_spatial_modes>{}, [&](auto i) {
|
||||
tma_lower_corner[i] = static_cast<int32_t>(get<i>(lower_corner_whd));
|
||||
});
|
||||
|
||||
cute::array<int32_t, num_spatial_modes> tma_upper_corner{};
|
||||
for_each(make_seq<num_spatial_modes>{}, [&](auto i) {
|
||||
tma_upper_corner[i] = static_cast<int32_t>(get<i>(upper_corner_whd));
|
||||
});
|
||||
|
||||
Im2ColTmaDescriptor tma_desc;
|
||||
|
||||
#if (__CUDACC_VER_MAJOR__ >= 12)
|
||||
|
||||
CUtensorMapDataType tma_format = TMA::to_CUtensorMapDataType<value_type>();
|
||||
CUtensorMapInterleave tma_interleave = CU_TENSOR_MAP_INTERLEAVE_NONE;
|
||||
CUtensorMapL2promotion tma_l2Promotion = CU_TENSOR_MAP_L2_PROMOTION_NONE;
|
||||
CUtensorMapFloatOOBfill tma_oob_fill = CU_TENSOR_MAP_FLOAT_OOB_FILL_NONE;
|
||||
CUtensorMapSwizzle tma_swizzle = TMA::to_CUtensorMapSwizzle(detail::get_tma_swizzle_bits(smem_swizzle));
|
||||
|
||||
CUresult encode_result = cuTensorMapEncodeIm2col(
|
||||
&tma_desc,
|
||||
tma_format,
|
||||
num_total_modes,
|
||||
gmem_address,
|
||||
gmem_prob_shape.data(),
|
||||
gmem_prob_stride.data() + 1, // gmem_prob_stride[0] implicitly sizeof(value_type)
|
||||
tma_lower_corner.data(),
|
||||
tma_upper_corner.data(),
|
||||
range_c,
|
||||
range_whdn,
|
||||
tma_traversal_strides.data(),
|
||||
tma_interleave,
|
||||
tma_swizzle,
|
||||
tma_l2Promotion,
|
||||
tma_oob_fill);
|
||||
|
||||
// The extra asserts help indicate the error's cause.
|
||||
assert(encode_result != CUDA_ERROR_DEINITIALIZED);
|
||||
assert(encode_result != CUDA_ERROR_NOT_INITIALIZED);
|
||||
assert(encode_result != CUDA_ERROR_INVALID_CONTEXT);
|
||||
assert(encode_result != CUDA_ERROR_INVALID_VALUE);
|
||||
assert(encode_result == CUDA_SUCCESS);
|
||||
|
||||
#endif // (__CUDACC_VER_MAJOR__ >= 12)
|
||||
//
|
||||
// Calculate gemm shapes and linearized shapes based on tma layout tiling.
|
||||
//
|
||||
|
||||
// Compute [w, h, d, n]
|
||||
// q/p/z = (w/h/d + (upper_corner_whd - lower_corner_whd - 1)) / stride_whd + 1
|
||||
auto gemm_mn_ = cute::transform(cute::make_seq<num_spatial_modes>{}, [&](auto i) {
|
||||
return (shape<i+1>(tensor_cwhdn) + get<i>(upper_corner_whd) - get<i>(lower_corner_whd) - Int<1>{}) / get<i>(stride_whd) + Int<1>{};
|
||||
});
|
||||
auto gemm_mn = append(gemm_mn_, shape<num_spatial_modes+1>(tensor_cwhdn));
|
||||
|
||||
// Compute [c, s, r, t]
|
||||
// fprop/wgrad, s/r/t = 1 + (upper_padding_whd - upper_corner_whd) / stride_srt
|
||||
// wgrad, s/r/t = 1 + (lower_padding_whd - lower_corner_whd) / stride_srt
|
||||
auto gemm_k_ = cute::transform(cute::make_seq<num_spatial_modes>{}, [&](auto i) {
|
||||
auto padding_size = conditional_return(get<i>(stride_srt) > Int<0>{},
|
||||
get<i>(upper_padding_whd) - get<i>(upper_corner_whd),
|
||||
get<i>(lower_corner_whd) - get<i>(lower_padding_whd));
|
||||
return Int<1>{} + padding_size / get<i>(stride_srt);
|
||||
});
|
||||
auto gemm_k = prepend(gemm_k_, shape<0>(tensor_cwhdn));
|
||||
|
||||
// For fprop/dgrad kernel, gemm_shapes is ((q, p, z, n), (c, s, r, t))
|
||||
// For wgrad kernel, gemm_shapes is ((c, s, r, t), (q, p, z, n))
|
||||
auto gemm_shapes_common = make_shape(gemm_mn, gemm_k);
|
||||
auto gemm_shapes = make_shape(
|
||||
basis_get(stride<0,1>(tma_layout_vt), gemm_shapes_common),
|
||||
basis_get(stride<0,0>(tma_layout_vt), gemm_shapes_common));
|
||||
|
||||
// For fprop/dgrad kernel, linearized shapes is (whdn, (c, s, r, t))
|
||||
// For wgrad kernel linearized shapes is ((c, s, r, t), whdn)
|
||||
auto linear_shapes_common = make_shape(size(gemm_mn), gemm_k);
|
||||
auto linear_shapes = make_shape(
|
||||
basis_get(stride<0,1>(tma_layout_vt), linear_shapes_common),
|
||||
basis_get(stride<0,0>(tma_layout_vt), linear_shapes_common));
|
||||
|
||||
//
|
||||
// Calculate gmem basis stride based on tma layout tiling.
|
||||
//
|
||||
|
||||
auto tma_basis_scale = make_shape(Int<1>{}, stride_whd, Int<1>{}, stride_srt);
|
||||
auto tma_basis = elem_scale(tma_basis_scale, make_basis_like(tma_basis_scale));
|
||||
|
||||
auto gbasis_strides_common = make_stride(
|
||||
append(get<1>(tma_basis), get<2>(tma_basis)),
|
||||
prepend(get<3>(tma_basis), get<0>(tma_basis))); // ((w,h,d,n),(c,s,r,t))
|
||||
auto gbasis_strides = make_stride(
|
||||
basis_get(stride<0,1>(tma_layout_vt), gbasis_strides_common),
|
||||
basis_get(stride<0,0>(tma_layout_vt), gbasis_strides_common));
|
||||
|
||||
//
|
||||
// Create tma tensor
|
||||
//
|
||||
|
||||
auto lower_corner = make_arithmetic_tuple(Int<0>{}, lower_corner_whd, Int<0>{}, lower_srt);
|
||||
|
||||
auto tensor_multimode = make_tensor(ArithmeticTupleIterator(lower_corner), gemm_shapes, gbasis_strides);
|
||||
auto tensor_linear = make_identity_tensor(linear_shapes);
|
||||
auto tma_tensor = make_tensor(tensor_multimode.data(), composition(
|
||||
tensor_multimode.layout(),
|
||||
tensor_linear(Int<0>{}),
|
||||
tensor_linear.layout()));
|
||||
|
||||
return cute::make_tuple(tma_desc, tma_tensor);
|
||||
}
|
||||
|
||||
/// Make a TiledCopy for im2col TMA load.
|
||||
///
|
||||
/// @param copy_op The copy implementation: either
|
||||
/// SM90_TMA_LOAD_IM2COL or SM90_TMA_LOAD_IM2COL_MULTICAST.
|
||||
///
|
||||
/// @param tensor_cwhdn The global tensor to use for im2col TMA loads.
|
||||
/// For Fprop convolutions, this is the activation tensor. This is
|
||||
/// the "original tensor that points to global memory, not the
|
||||
/// coordinate (im2col-transformed) tensor.
|
||||
///
|
||||
/// @param slayout Layout of shared memory tile.
|
||||
///
|
||||
/// @param stride_whd The traversal strides convolution
|
||||
/// parameter.
|
||||
///
|
||||
/// @return TiledCopy specialization for im2col TMA loads.
|
||||
template <class CopyOp,
|
||||
class GEngine, class GLayout,
|
||||
class SLayout,
|
||||
class TShape, class TStride,
|
||||
class VShape, class VStride,
|
||||
class LowerCornerStride,
|
||||
class UpperCornerStride,
|
||||
class LowerPaddingStride,
|
||||
class UpperPaddingStride,
|
||||
class TraversalStride,
|
||||
class LowerSRTStride,
|
||||
class DilationStride>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_tma_copy_im2col(CopyOp const& copy_op,
|
||||
Tensor<GEngine,GLayout> const& gtensor,
|
||||
SLayout const& slayout,
|
||||
Layout<TShape,TStride> const& cta_t_map, // CTA tid -> logical TMA tid
|
||||
Layout<VShape,VStride> const& cta_v_map, // CTA vid -> gmem coord
|
||||
LowerCornerStride const& lower_corner_whd,
|
||||
UpperCornerStride const& upper_corner_whd,
|
||||
LowerPaddingStride const& lower_padding_whd,
|
||||
UpperPaddingStride const& upper_padding_whd,
|
||||
TraversalStride const& stride_whd, // traversal stride
|
||||
LowerSRTStride const& lower_srt,
|
||||
DilationStride const& stride_srt) // dilation
|
||||
{
|
||||
//
|
||||
// TMA parameter checking
|
||||
//
|
||||
|
||||
CUTE_STATIC_ASSERT_V(product_each(shape(slayout)) == product_each(shape(cta_v_map)),
|
||||
"TMA requires CTA_Tile and SLayout top-level shape equivalence.");
|
||||
CUTE_STATIC_ASSERT_V(size(slayout) % cosize(cta_t_map) == Int<0>{},
|
||||
"Number of active CTAs in TMA must divide domain size of slayout.");
|
||||
|
||||
//
|
||||
// TMA slayout manipulation
|
||||
//
|
||||
|
||||
// Invert the smem to get the largest contiguous vector in the smem layout
|
||||
auto inv_smem_layout = right_inverse(get_nonswizzle_portion(slayout));
|
||||
// trunc_smem_idx -> trunc_smem_coord
|
||||
|
||||
// Map from smem idx to a gmem mode
|
||||
auto sidx_to_gmode = coalesce(composition(cta_v_map, inv_smem_layout));
|
||||
|
||||
#if 0
|
||||
print("g_layout : "); print(gtensor.layout()); print("\n");
|
||||
print("s_layout : "); print(slayout); print("\n");
|
||||
print("cta_t_map : "); print(cta_t_map); print("\n");
|
||||
print("cta_v_map : "); print(cta_v_map); print("\n");
|
||||
print("inv_smem : "); print(inv_smem_layout); print("\n");
|
||||
print("sidx_to_gmode : "); print(sidx_to_gmode); print("\n");
|
||||
#endif
|
||||
|
||||
//
|
||||
// TMA gtensor manipulation
|
||||
//
|
||||
|
||||
// Generate a TupleBasis for the gtensor
|
||||
auto glayout_basis = make_identity_layout(product_each(shape(gtensor)));
|
||||
|
||||
// Tile the modes of gtensor with the truncated cta_v_map o inv_smem_layout_trunc
|
||||
auto tma_layout_full = flatten(composition(glayout_basis, sidx_to_gmode));
|
||||
|
||||
// Truncate any incompatibilities -- no starting in the middle of gmodes
|
||||
auto smem_rank = find_if(stride(tma_layout_full), [](auto e) {
|
||||
[[maybe_unused]] auto v = basis_value(e);
|
||||
return not is_constant<1,decltype(v)>{};
|
||||
});
|
||||
static_assert(smem_rank >= 2, "IM2COL expects at least 2 modes of the smem to vectorize with gmem.");
|
||||
// IM2COL uses a maximum of 2 modes
|
||||
constexpr int smem_tma_rank = cute::min(int(smem_rank), 2);
|
||||
|
||||
// Keep only the static-1 basis modes into gmem
|
||||
auto tma_layout_trunc = take<0,smem_tma_rank>(tma_layout_full);
|
||||
|
||||
// Split according to the portion each multicast CTA will be responsible for
|
||||
auto tma_layout_vt = logical_divide(tma_layout_trunc, shape_div(size(tma_layout_trunc), cosize(cta_t_map)));
|
||||
|
||||
#if 0
|
||||
print("glayout_basis : "); print(glayout_basis); print("\n");
|
||||
print("tma_layout_full : "); print(tma_layout_full); print("\n");
|
||||
|
||||
print("tma_layout_trunc: "); print(tma_layout_trunc); print("\n");
|
||||
print("tma_layout_vt : "); print(tma_layout_vt); print("\n");
|
||||
#endif
|
||||
|
||||
auto range_c = size<0,0>(tma_layout_vt);
|
||||
auto range_whdn = size<0,1>(tma_layout_vt);
|
||||
|
||||
Tensor gtensor_cwhdn = make_tensor(gtensor.data(),
|
||||
flatten(make_layout(basis_get(stride<0,0>(tma_layout_vt), gtensor.layout()),
|
||||
basis_get(stride<0,1>(tma_layout_vt), gtensor.layout()))));
|
||||
|
||||
auto [tma_desc, tma_tensor] = make_im2col_tma_copy_desc(
|
||||
gtensor_cwhdn,
|
||||
range_c,
|
||||
range_whdn,
|
||||
detail::get_swizzle_portion(slayout),
|
||||
tma_layout_vt,
|
||||
lower_corner_whd,
|
||||
upper_corner_whd,
|
||||
lower_padding_whd,
|
||||
upper_padding_whd,
|
||||
stride_whd,
|
||||
lower_srt,
|
||||
stride_srt);
|
||||
|
||||
//
|
||||
// Construct the Copy_Traits
|
||||
//
|
||||
|
||||
using T = typename GEngine::value_type;
|
||||
constexpr int num_bits_per_tma = decltype(size<0>(tma_layout_vt))::value * sizeof(T) * 8;
|
||||
|
||||
using Traits = Copy_Traits<CopyOp, cute::C<num_bits_per_tma>, decltype(tma_tensor)>;
|
||||
|
||||
#if 0
|
||||
print("num_bits : "); print(NumBitsPerTMA{}); print("\n");
|
||||
#endif
|
||||
|
||||
Traits tma_traits{tma_desc, tma_tensor};
|
||||
|
||||
//
|
||||
// Construct the TiledCopy
|
||||
//
|
||||
|
||||
auto cta_tiler = product_each(shape(cta_v_map));
|
||||
|
||||
// (CTA V, CTA T) -> smem_coord
|
||||
auto layout_vt = composition(inv_smem_layout, make_layout(shape(tma_layout_vt)));
|
||||
// Scale that up to cover all of the smem_coords
|
||||
//
|
||||
// The smem vector might not cover all of the tile,
|
||||
// so multiply it up to cover the entire tile.
|
||||
// "T" here (the parallel index) is a CTA index.
|
||||
auto layout_VT = tile_to_shape(layout_vt, make_shape(size(cta_v_map)/size<1>(layout_vt), size<1>(layout_vt)));
|
||||
// Flip it and change the domain of the T from logical thr to thr_idx
|
||||
auto layout_TV = make_layout(composition(layout<1>(layout_VT), cta_t_map), layout<0>(layout_VT));
|
||||
|
||||
#if 0
|
||||
print("cta_tiler : "); print(cta_tiler); print("\n");
|
||||
print("layout_VT : "); print(layout_VT); print("\n");
|
||||
print("layout_TV : "); print(layout_TV); print("\n");
|
||||
#endif
|
||||
|
||||
using T = typename GEngine::value_type;
|
||||
return TiledCopy<Copy_Atom<Traits,T>, decltype(layout_TV), decltype(cta_tiler)>{tma_traits};
|
||||
}
|
||||
|
||||
/// Make a TiledCopy for im2col TMA with no offsets.
|
||||
/// E.g. im2col TMA load for C and im2col TMA store for D.
|
||||
template <class CopyOp,
|
||||
class GEngine, class GLayout,
|
||||
class SLayout,
|
||||
class TShape, class TStride,
|
||||
class VShape, class VStride>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_tma_copy_im2col(CopyOp const& copy_op,
|
||||
Tensor<GEngine,GLayout> const& gtensor,
|
||||
SLayout const& slayout,
|
||||
Layout<TShape,TStride> const& cta_t_map, // CTA tid -> logical TMA tid
|
||||
Layout<VShape,VStride> const& cta_v_map) // CTA vid -> gmem coord
|
||||
{
|
||||
constexpr int num_spatial_modes = rank<0>(GLayout{}) - 1;
|
||||
return make_tma_copy_im2col(copy_op, gtensor, slayout, cta_t_map, cta_v_map,
|
||||
append<num_spatial_modes>(Stride<_0>{}, Int<0>{}), // lower_corner_whd
|
||||
append<num_spatial_modes>(Stride<_0>{}, Int<0>{}), // upper_corner_whd
|
||||
append<num_spatial_modes>(Stride<_0>{}, Int<0>{}), // lower_padding_whd
|
||||
append<num_spatial_modes>(Stride<_0>{}, Int<0>{}), // upper_padding_whd
|
||||
append<num_spatial_modes>(Stride<_1>{}, Int<1>{}), // stride_whd
|
||||
append<num_spatial_modes>(Stride<_0>{}, Int<0>{}), // lower_srt
|
||||
append<num_spatial_modes>(Stride<_1>{}, Int<1>{})); // stride_srt
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout,
|
||||
class CTATiler,
|
||||
class MulticastSize,
|
||||
class LowerCornerStride,
|
||||
class UpperCornerStride,
|
||||
class LowerPaddingStride,
|
||||
class UpperPaddingStride,
|
||||
class TraversalStride,
|
||||
class LowerSRTStride,
|
||||
class DilationStride>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout,
|
||||
CTATiler const& cta_tiler,
|
||||
MulticastSize const& multicast_size,
|
||||
LowerCornerStride const& lower_corner_whd,
|
||||
UpperCornerStride const& upper_corner_whd,
|
||||
LowerPaddingStride const& lower_padding_whd,
|
||||
UpperPaddingStride const& upper_padding_whd,
|
||||
TraversalStride const& stride_whd,
|
||||
LowerSRTStride const& lower_srt,
|
||||
DilationStride const& stride_srt)
|
||||
{
|
||||
auto cta_v_tile = make_identity_layout(product_each(shape(tensor_cwhdn))).compose(cta_tiler);
|
||||
auto cta_t_tile = make_layout(multicast_size);
|
||||
|
||||
return detail::make_tma_copy_im2col(copy_op, tensor_cwhdn,
|
||||
slayout, cta_t_tile, cta_v_tile,
|
||||
lower_corner_whd, upper_corner_whd, lower_padding_whd, upper_padding_whd, stride_whd, lower_srt, stride_srt);
|
||||
}
|
||||
|
||||
// Explicit default for multicast_size
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout,
|
||||
class CTATiler,
|
||||
class LowerCornerStride,
|
||||
class UpperCornerStride,
|
||||
class LowerPaddingStride,
|
||||
class UpperPaddingStride,
|
||||
class TraversalStride,
|
||||
class LowerSRTStride,
|
||||
class DilationStride>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout,
|
||||
CTATiler const& cta_tiler,
|
||||
LowerCornerStride const& lower_corner_whd,
|
||||
UpperCornerStride const& upper_corner_whd,
|
||||
LowerPaddingStride const& lower_padding_whd,
|
||||
UpperPaddingStride const& upper_padding_whd,
|
||||
TraversalStride const& stride_whd,
|
||||
LowerSRTStride const& lower_srt,
|
||||
DilationStride const& stride_srt)
|
||||
{
|
||||
return make_im2col_tma_copy(copy_op, tensor_cwhdn, slayout, cta_tiler, Int<1>{},
|
||||
lower_corner_whd, upper_corner_whd, lower_padding_whd, upper_padding_whd, stride_whd, lower_srt, stride_srt);
|
||||
}
|
||||
|
||||
// Explicit default for cta_tiler and multicast_size
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout,
|
||||
class LowerCornerStride,
|
||||
class UpperCornerStride,
|
||||
class LowerPaddingStride,
|
||||
class UpperPaddingStride,
|
||||
class TraversalStride,
|
||||
class LowerSRTStride,
|
||||
class DilationStride>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout,
|
||||
LowerCornerStride const& lower_corner_whd,
|
||||
UpperCornerStride const& upper_corner_whd,
|
||||
LowerPaddingStride const& lower_padding_whd,
|
||||
UpperPaddingStride const& upper_padding_whd,
|
||||
TraversalStride const& stride_whd,
|
||||
LowerSRTStride const& lower_srt,
|
||||
DilationStride const& stride_srt)
|
||||
{
|
||||
return make_im2col_tma_copy(copy_op, tensor_cwhdn, slayout, product_each(shape(slayout)), Int<1>{},
|
||||
lower_corner_whd, upper_corner_whd, lower_padding_whd, upper_padding_whd, stride_whd, lower_srt, stride_srt);
|
||||
}
|
||||
|
||||
// No offsets copy.
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout,
|
||||
class CTATiler,
|
||||
class MulticastSize>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout,
|
||||
CTATiler const& cta_tiler,
|
||||
MulticastSize const& multicast_size)
|
||||
{
|
||||
auto cta_v_tile = make_identity_layout(product_each(shape(tensor_cwhdn))).compose(cta_tiler);
|
||||
auto cta_t_tile = make_layout(multicast_size);
|
||||
|
||||
return detail::make_tma_copy_im2col(copy_op, tensor_cwhdn, slayout, cta_t_tile, cta_v_tile);
|
||||
}
|
||||
|
||||
// Explicit default for multicast_size
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout,
|
||||
class CTATiler>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout,
|
||||
CTATiler const& cta_tiler)
|
||||
{
|
||||
return make_im2col_tma_copy(copy_op, tensor_cwhdn, slayout, cta_tiler, Int<1>{});
|
||||
}
|
||||
|
||||
// Explicit default for cta_tiler and multicast_size
|
||||
template <class CopyOp,
|
||||
class Engine0, class Layout0,
|
||||
class SLayout>
|
||||
CUTE_HOST_RTC
|
||||
auto
|
||||
make_im2col_tma_copy(CopyOp const& copy_op,
|
||||
Tensor<Engine0, Layout0> const& tensor_cwhdn,
|
||||
SLayout const& slayout)
|
||||
{
|
||||
return make_im2col_tma_copy(copy_op, tensor_cwhdn, slayout, product_each(shape(slayout)), Int<1>{});
|
||||
}
|
||||
|
||||
} // namespace cute
|
||||
@@ -38,6 +38,8 @@
|
||||
#include <cute/atom/copy_traits.hpp>
|
||||
#include <cute/atom/copy_atom.hpp>
|
||||
|
||||
#include <cute/algorithm/prefetch.hpp>
|
||||
|
||||
#include <cute/numeric/integral_ratio.hpp>
|
||||
|
||||
namespace cute
|
||||
@@ -53,77 +55,55 @@ struct AuxTmaParams {
|
||||
static_assert(is_static<TmaSwizzle>::value);
|
||||
};
|
||||
|
||||
// Utility for unpacking TMA_LOAD arguments into a CopyOp
|
||||
template <class CopyOp>
|
||||
struct TMA_LOAD_Unpack
|
||||
{
|
||||
template <class... Args,
|
||||
class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits<CopyOp, Args...> const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
auto src_coord = src.data().coord_;
|
||||
if constexpr (detail::is_prefetch<CopyOp>) {
|
||||
return detail::copy_explode<CopyOp>(traits.opargs_, tuple_seq<decltype(traits.opargs_)>{},
|
||||
src_coord, tuple_seq<decltype(src_coord)>{});
|
||||
} else {
|
||||
static_assert(is_smem<TD>::value, "SM90_TMA_LOAD requires the destination be shared memory.");
|
||||
void* dst_ptr = cute::raw_pointer_cast(dst.data());
|
||||
#if 0
|
||||
auto [c0,c1,c2,c3,c4] = append<5>(src_coord, 0);
|
||||
printf("THR (%d,%d,%d) BLK (%d,%d,%d) TMACRD (%d,%d,%d,%d,%d) SMEMADDR (%p)\n",
|
||||
threadIdx.x, threadIdx.y, threadIdx.z,
|
||||
blockIdx.x, blockIdx.y, blockIdx.z,
|
||||
int32_t(c0), int32_t(c1), int32_t(c2), int32_t(c3), int32_t(c4), dst_ptr);
|
||||
#endif
|
||||
return detail::copy_explode<CopyOp>(traits.opargs_, tuple_seq<decltype(traits.opargs_)>{},
|
||||
make_tuple(dst_ptr), seq<0>{},
|
||||
src_coord, tuple_seq<decltype(src_coord)>{});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_LOAD ///////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SM90_TMA_LOAD_OP : SM90_TMA_LOAD {};
|
||||
|
||||
// The executable SM90_TMA_LOAD with tma_desc and tma_mbar
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_OP, NumBitsPerTMA>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD arguments
|
||||
TmaDescriptor const& tma_desc_;
|
||||
uint64_t& tma_load_mbar_;
|
||||
|
||||
template <class Coord, int... Is>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_unpack_(void const* const dst_ptr,
|
||||
Coord const& src_coord, seq<Is...>) const
|
||||
{
|
||||
#if 0
|
||||
auto [c0,c1,c2,c3,c4] = append<5>(src_coord, 0);
|
||||
printf("THR (%d,%d,%d) BLK (%d,%d,%d) TMACRD (%d,%d,%d,%d,%d) SMEMADDR (%p)\n",
|
||||
threadIdx.x, threadIdx.y, threadIdx.z,
|
||||
blockIdx.x, blockIdx.y, blockIdx.z,
|
||||
int32_t(c0), int32_t(c1), int32_t(c2), int32_t(c3), int32_t(c4), dst_ptr);
|
||||
#endif
|
||||
|
||||
SM90_TMA_LOAD::copy(&tma_desc_, tma_load_mbar_,
|
||||
dst_ptr, get<Is>(src_coord)...);
|
||||
}
|
||||
|
||||
// This is the copy_unpack dispatch for this Copy_Traits
|
||||
// Src needs to be a gmem tensor with TmaCoordIterator .data()
|
||||
// Dst needs to be a smem tensor
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr
|
||||
void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_smem<TD>::value, "Expected smem dst for SM90_TMA_LOAD");
|
||||
|
||||
traits.copy_unpack_(cute::raw_pointer_cast(dst.data()), src.data().coord_, tuple_seq<decltype(src.data().coord_)>{});
|
||||
}
|
||||
};
|
||||
|
||||
// The non-executable SM90_TMA_LOAD with tma_desc and no tma_mbar
|
||||
// Use .with(tma_mbar) to construct an executable version
|
||||
template <class NumBitsPerTMA, class AuxParams_>
|
||||
struct Copy_Traits<SM90_TMA_LOAD, NumBitsPerTMA, AuxParams_>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
@@ -144,7 +124,7 @@ struct Copy_Traits<SM90_TMA_LOAD, NumBitsPerTMA, AuxParams_>
|
||||
Copy_Traits<SM90_TMA_LOAD_OP, NumBitsPerTMA>
|
||||
with(uint64_t& tma_mbar, [[maybe_unused]] uint16_t const& multicast_mask = 0) const {
|
||||
// We accept multicast_mask here to keep the API for both atoms consistent
|
||||
return {tma_desc_, tma_mbar};
|
||||
return {{}, {&tma_desc_, &tma_mbar}};
|
||||
}
|
||||
|
||||
// Construct an executable SM90_TMA_LOAD with tma_mbar (temp. overloaded for grouped gemm/ptr array gemm)
|
||||
@@ -152,7 +132,7 @@ struct Copy_Traits<SM90_TMA_LOAD, NumBitsPerTMA, AuxParams_>
|
||||
Copy_Traits<SM90_TMA_LOAD_OP, NumBitsPerTMA>
|
||||
with(TmaDescriptor const* new_tma_desc, uint64_t& tma_mbar, [[maybe_unused]] uint16_t const& multicast_mask = 0) const {
|
||||
// We accept multicast_mask here to keep the API for both atoms consistent
|
||||
return {*new_tma_desc, tma_mbar};
|
||||
return {{}, {new_tma_desc, &tma_mbar}};
|
||||
}
|
||||
|
||||
// Generate the TMA coord tensor
|
||||
@@ -173,72 +153,65 @@ struct Copy_Traits<SM90_TMA_LOAD, NumBitsPerTMA, AuxParams_>
|
||||
Tensor<TD,DLayout> & dst) = delete;
|
||||
};
|
||||
|
||||
// The executable SM90_TMA_LOAD with tma_desc and tma_mbar
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_OP, NumBitsPerTMA>
|
||||
: TMA_LOAD_Unpack<SM90_TMA_LOAD_OP>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD arguments
|
||||
tuple<
|
||||
TmaDescriptor const*,
|
||||
uint64_t* // smem mbarrier
|
||||
> const opargs_;
|
||||
};
|
||||
|
||||
// The prefetch for SM90_TMA_LOAD with tma_desc
|
||||
template <class NumBitsPerTMA, class... Args>
|
||||
struct Copy_Traits<SM90_TMA_LOAD::PREFETCH, NumBitsPerTMA, Args...>
|
||||
: TMA_LOAD_Unpack<SM90_TMA_LOAD::PREFETCH>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD::PREFETCH arguments
|
||||
tuple<TmaDescriptor const*> const opargs_;
|
||||
|
||||
// Construct with any other Traits' TMA Desc
|
||||
template <class... CopyArgs>
|
||||
CUTE_HOST_DEVICE
|
||||
Copy_Traits(Copy_Traits<CopyArgs...> const& traits)
|
||||
: opargs_({&traits.tma_desc_}) {}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_LOAD_MULTICAST /////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct SM90_TMA_LOAD_MULTICAST_OP : SM90_TMA_LOAD_MULTICAST {};
|
||||
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_MULTICAST_OP, NumBitsPerTMA>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD_MULTICAST arguments
|
||||
TmaDescriptor const& tma_desc_;
|
||||
uint64_t& tma_load_mbar_;
|
||||
uint16_t const& multicast_mask_;
|
||||
|
||||
template <class Coord, int... Is>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
copy_unpack_(void const* const dst_ptr,
|
||||
Coord const& src_coord, seq<Is...>) const
|
||||
{
|
||||
#if 0
|
||||
auto [c0,c1,c2,c3,c4] = append<5>(src_coord, 0);
|
||||
printf("THR (%d,%d,%d) BLK (%d,%d,%d) TMACRD (%d,%d,%d,%d,%d) SMEMADDR (%p)\n",
|
||||
threadIdx.x, threadIdx.y, threadIdx.z,
|
||||
blockIdx.x, blockIdx.y, blockIdx.z,
|
||||
int32_t(c0), int32_t(c1), int32_t(c2), int32_t(c3), int32_t(c4), dst_ptr);
|
||||
#endif
|
||||
|
||||
SM90_TMA_LOAD_MULTICAST::copy(&tma_desc_, tma_load_mbar_, multicast_mask_,
|
||||
dst_ptr, get<Is>(src_coord)...);
|
||||
}
|
||||
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr
|
||||
void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_smem<TD>::value, "Expected smem dst for SM90_TMA_LOAD_MULTICAST");
|
||||
|
||||
traits.copy_unpack_(cute::raw_pointer_cast(dst.data()), src.data().coord_, tuple_seq<decltype(src.data().coord_)>{});
|
||||
}
|
||||
};
|
||||
|
||||
// The non-executable SM90_TMA_LOAD_MULTICAST with tma_desc and no tma_mbar
|
||||
// Use .with(tma_mbar, multicast_mask) to construct an executable version
|
||||
template <class NumBitsPerTMA, class AuxParams_>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_MULTICAST, NumBitsPerTMA, AuxParams_>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
@@ -258,14 +231,14 @@ struct Copy_Traits<SM90_TMA_LOAD_MULTICAST, NumBitsPerTMA, AuxParams_>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_TMA_LOAD_MULTICAST_OP, NumBitsPerTMA>
|
||||
with(uint64_t& tma_load_mbar, uint16_t const& multicast_mask) const {
|
||||
return {tma_desc_, tma_load_mbar, multicast_mask};
|
||||
return {{}, {&tma_desc_, &tma_load_mbar, multicast_mask}};
|
||||
}
|
||||
|
||||
// Construct an executable SM90_TMA_LOAD_MULTICAST_OP with tma_mbar (temp. overloaded for grouped gemm/ptr array gemm)
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_TMA_LOAD_MULTICAST_OP, NumBitsPerTMA>
|
||||
with(TmaDescriptor const* new_tma_desc, uint64_t& tma_load_mbar, uint16_t const& multicast_mask) const {
|
||||
return {*new_tma_desc, tma_load_mbar, multicast_mask};
|
||||
return {{}, {new_tma_desc, &tma_load_mbar, multicast_mask}};
|
||||
}
|
||||
|
||||
// Generate the TMA coord tensor
|
||||
@@ -286,6 +259,27 @@ struct Copy_Traits<SM90_TMA_LOAD_MULTICAST, NumBitsPerTMA, AuxParams_>
|
||||
Tensor<TD,DLayout> & dst) = delete;
|
||||
};
|
||||
|
||||
// The executable SM90_TMA_LOAD_MULTICAST with tma_desc and tma_mbar and multicast_mask
|
||||
template <class NumBitsPerTMA>
|
||||
struct Copy_Traits<SM90_TMA_LOAD_MULTICAST_OP, NumBitsPerTMA>
|
||||
: TMA_LOAD_Unpack<SM90_TMA_LOAD_MULTICAST_OP>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_LOAD_MULTICAST arguments
|
||||
tuple<
|
||||
TmaDescriptor const*,
|
||||
uint64_t*, // smem mbarrier
|
||||
uint16_t // multicast mask
|
||||
> const opargs_;
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_STORE //////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -293,6 +287,68 @@ struct Copy_Traits<SM90_TMA_LOAD_MULTICAST, NumBitsPerTMA, AuxParams_>
|
||||
// The executable SM90_TMA_STORE with tma_desc
|
||||
template <class NumBitsPerTMA, class AuxParams_>
|
||||
struct Copy_Traits<SM90_TMA_STORE, NumBitsPerTMA, AuxParams_>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
// Map from (src-thr,src-val) to bit
|
||||
using SrcLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Map from (dst-thr,dst-val) to bit
|
||||
using DstLayout = Layout<Shape<_1,NumBitsPerTMA>>;
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_STORE arguments
|
||||
TmaDescriptor tma_desc_;
|
||||
using AuxParams = AuxParams_;
|
||||
AuxParams aux_params_;
|
||||
|
||||
// Return TmaDescriptor/TensorMap
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
TmaDescriptor const*
|
||||
get_tma_descriptor() const {
|
||||
return &tma_desc_;
|
||||
}
|
||||
|
||||
// Generate the TMA coord tensor
|
||||
template <class GShape>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
auto
|
||||
get_tma_tensor(GShape const& g_shape) const {
|
||||
static_assert(is_congruent<decltype(g_shape), decltype(aux_params_.g_stride_)>::value);
|
||||
return make_counting_tensor(make_layout(g_shape, aux_params_.g_stride_));
|
||||
}
|
||||
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_smem<TS>::value, "Expected smem src for SM90_TMA_STORE");
|
||||
//static_assert(is_gmem<TD>::value, "Expected gmem dst for SM90_TMA_STORE"); // TMA spoofed src tensor
|
||||
|
||||
void const* const desc_ptr = &(traits.tma_desc_);
|
||||
void const* const src_ptr = cute::raw_pointer_cast(src.data());
|
||||
auto dst_coord = dst.data().coord_;
|
||||
#if 0
|
||||
auto [c0,c1,c2,c3,c4] = append<5>(dst_coord, 0);
|
||||
printf("THR (%d,%d,%d) BLK (%d,%d,%d) TMACRD (%d,%d,%d,%d,%d) SMEMADDR (%p)\n",
|
||||
threadIdx.x, threadIdx.y, threadIdx.z,
|
||||
blockIdx.x, blockIdx.y, blockIdx.z,
|
||||
int32_t(c0), int32_t(c1), int32_t(c2), int32_t(c3), int32_t(c4), src_ptr);
|
||||
#endif
|
||||
return detail::copy_explode<SM90_TMA_STORE>(make_tuple(desc_ptr, src_ptr), seq<0,1>{},
|
||||
dst_coord, tuple_seq<decltype(dst_coord)>{});
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////// TMA_REDUCE_ADD //////////////////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// The executable SM90_TMA_REDUCE_ADD with tma_desc
|
||||
template <class NumBitsPerTMA, class AuxParams_>
|
||||
struct Copy_Traits<SM90_TMA_REDUCE_ADD, NumBitsPerTMA, AuxParams_>
|
||||
{
|
||||
using ThrID = Layout<_1>;
|
||||
|
||||
@@ -304,7 +360,7 @@ struct Copy_Traits<SM90_TMA_STORE, NumBitsPerTMA, AuxParams_>
|
||||
// Reference map from (thr,val) to bit
|
||||
using RefLayout = SrcLayout;
|
||||
|
||||
// SM90_TMA_STORE arguments
|
||||
// SM90_TMA_REDUCE_ADD arguments
|
||||
TmaDescriptor tma_desc_;
|
||||
using AuxParams = AuxParams_;
|
||||
AuxParams aux_params_;
|
||||
@@ -339,7 +395,7 @@ struct Copy_Traits<SM90_TMA_STORE, NumBitsPerTMA, AuxParams_>
|
||||
int32_t(c0), int32_t(c1), int32_t(c2), int32_t(c3), int32_t(c4), src_ptr);
|
||||
#endif
|
||||
|
||||
SM90_TMA_STORE::copy(&tma_desc_,
|
||||
SM90_TMA_REDUCE_ADD::copy(&tma_desc_,
|
||||
src_ptr, get<Is>(dst_coord)...);
|
||||
}
|
||||
|
||||
@@ -354,8 +410,8 @@ struct Copy_Traits<SM90_TMA_STORE, NumBitsPerTMA, AuxParams_>
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_smem<TS>::value, "Expected smem src for SM90_TMA_STORE");
|
||||
//static_assert(is_gmem<TD>::value, "Expected gmem dst for SM90_TMA_STORE"); // TMA spoofed src tensor
|
||||
static_assert(is_smem<TS>::value, "Expected smem src for SM90_TMA_REDUCE_ADD");
|
||||
//static_assert(is_gmem<TD>::value, "Expected gmem dst for SM90_TMA_REDUCE_ADD"); // TMA spoofed src tensor
|
||||
|
||||
traits.copy_unpack_(cute::raw_pointer_cast(src.data()), dst.data().coord_, tuple_seq<decltype(dst.data().coord_)>{});
|
||||
}
|
||||
@@ -383,6 +439,13 @@ struct Copy_Traits<SM90_BULK_COPY_G2S, NumBitsPerTMA, OpArgs...>
|
||||
// 0: uint64_t* bulk_load_memory_barrier
|
||||
cute::tuple<OpArgs...> bulk_load_mbar_;
|
||||
|
||||
// Record the memory barrier for the instruction
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_BULK_COPY_G2S, NumBitsPerTMA, uint64_t*>
|
||||
with(uint64_t& bulk_mbar) const {
|
||||
return {{&bulk_mbar}};
|
||||
}
|
||||
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr
|
||||
@@ -395,15 +458,29 @@ struct Copy_Traits<SM90_BULK_COPY_G2S, NumBitsPerTMA, OpArgs...>
|
||||
"Extra arguments not set. Set .with() before use.");
|
||||
static_assert(is_gmem<TS>::value, "Expected gmem src for SM90_BULK_COPY_G2S");
|
||||
static_assert(is_smem<TD>::value, "Expected smem dst for SM90_BULK_COPY_G2S");
|
||||
SM90_BULK_COPY_G2S::copy(raw_pointer_cast(src.data()), *get<0>(traits.bulk_load_mbar_),
|
||||
SM90_BULK_COPY_G2S::copy(raw_pointer_cast(src.data()), get<0>(traits.bulk_load_mbar_),
|
||||
raw_pointer_cast(dst.data()), int32_t(NumBitsPerTMA::value / 8));
|
||||
}
|
||||
};
|
||||
|
||||
// Record the memory barrier for the instruction
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
Copy_Traits<SM90_BULK_COPY_G2S, NumBitsPerTMA, uint64_t*>
|
||||
with(uint64_t& bulk_mbar) const {
|
||||
return {{&bulk_mbar}};
|
||||
template <class NumBitsPerTMA, class... Args>
|
||||
struct Copy_Traits<SM90_BULK_COPY_G2S::PREFETCH, NumBitsPerTMA, Args...>
|
||||
: Copy_Traits<SM90_BULK_COPY_G2S, NumBitsPerTMA>
|
||||
{
|
||||
template <class... CopyArgs>
|
||||
CUTE_HOST_DEVICE
|
||||
Copy_Traits(Copy_Traits<CopyArgs...> const& traits) {}
|
||||
|
||||
template <class TS, class SLayout,
|
||||
class TD, class DLayout>
|
||||
CUTE_HOST_DEVICE friend constexpr
|
||||
void
|
||||
copy_unpack(Copy_Traits const& traits,
|
||||
Tensor<TS,SLayout> const& src,
|
||||
Tensor<TD,DLayout> & dst)
|
||||
{
|
||||
static_assert(is_gmem<TS>::value, "Expected gmem src for SM90_BULK_PREFETCH");
|
||||
SM90_BULK_COPY_G2S::PREFETCH::copy(raw_pointer_cast(src.data()), int32_t(NumBitsPerTMA::value / 8));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -653,7 +730,7 @@ template <class GEngine, class GLayout,
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
fill_tma_gmem_shape_stride(Tensor<GEngine,GLayout> const& gtensor, // Gmem Shapes and Strides, in units of TmaInternalType
|
||||
TmaGmemBasisStride const& tma_gbasis_stride, // Map Tma mode idx -> Gmem mode(s)
|
||||
TmaGmemBasisStride const& tma_gbasis_stride, // Map Tma mode idx -> Gmem mode(s)
|
||||
cute::array<ShapeT, TmaRank> & gmem_prob_shape, // Tma Shapes, uint32_t or uin64_t
|
||||
cute::array<uint64_t, TmaRank> & gmem_prob_stride) // Tma Strides
|
||||
{
|
||||
@@ -663,7 +740,7 @@ fill_tma_gmem_shape_stride(Tensor<GEngine,GLayout> const& gtensor, /
|
||||
using TmaInternalType = typename GEngine::value_type;
|
||||
constexpr int tma_rank = decltype(rank(tma_gbasis_stride))::value;
|
||||
static_assert(TmaRank >= tma_rank);
|
||||
|
||||
|
||||
auto gmem_shape = shape(gtensor);
|
||||
auto gmem_stride = stride(gtensor);
|
||||
// Use the indirections in tma_gbasis_stride into gtensor to construct the tma gmem shapes/strides
|
||||
@@ -703,12 +780,12 @@ template <class GEngine, class GLayout,
|
||||
class ShapeT, size_t TmaRank>
|
||||
CUTE_HOST_DEVICE constexpr
|
||||
void
|
||||
fill_tma_gmem_shape_stride(Copy_Traits<Op,Bits,Aux> const& tma_traits,
|
||||
fill_tma_gmem_shape_stride(Copy_Traits<Op,Bits,Aux> const& tma_traits,
|
||||
Tensor<GEngine,GLayout> const& gtensor, // Gmem Shapes and Strides, value_type = TmaInternalType
|
||||
cute::array<ShapeT, TmaRank> & gmem_prob_shape, // Tma Shapes, uint32_t or uin64_t
|
||||
cute::array<uint64_t, TmaRank> & gmem_prob_stride) // Tma Strides
|
||||
{
|
||||
return fill_tma_gmem_shape_stride(gtensor, stride(typename Aux::TmaGmemBasis{}),
|
||||
return fill_tma_gmem_shape_stride(gtensor, stride(typename Aux::TmaGmemBasis{}),
|
||||
gmem_prob_shape, gmem_prob_stride);
|
||||
}
|
||||
|
||||
@@ -824,7 +901,7 @@ make_tma_copy_desc(Tensor<GEngine,GLayout> const& gtensor, // The origin
|
||||
// Construct the descriptor
|
||||
//
|
||||
|
||||
TmaDescriptor tma_desc = {0};
|
||||
TmaDescriptor tma_desc{};
|
||||
|
||||
//
|
||||
// TMA general info
|
||||
@@ -897,7 +974,7 @@ make_tma_copy_desc(Tensor<GEngine,GLayout> const& gtensor, // The origin
|
||||
if constexpr (decltype(rank<j>(tma_gmem_basis_stride) == Int<1>{})::value) {
|
||||
return E<j>{}; // Return TMA Coord basis -- known scale of Int<1>{}
|
||||
} else {
|
||||
int32_t scale = ceil_div(int32_t(di * sizeof_bits_v<TmaInternalType> / cute::max(gmem_prob_stride[j], 16)), 8);
|
||||
int32_t scale = ceil_div(int32_t(di * sizeof_bits_v<TmaInternalType> / cute::max(gmem_prob_stride[j], uint64_t{16})), 8);
|
||||
return E<j>{} * scale; // Return TMA Coord basis -- with a dynamic scale factor
|
||||
}
|
||||
}
|
||||
@@ -948,7 +1025,7 @@ make_tma_copy_atom(CopyOp,
|
||||
// Construct the Copy_Traits
|
||||
//
|
||||
|
||||
constexpr int num_bits_per_tma = size(tma_gbasis) * sizeof_bits<TmaInternalType>::value;
|
||||
constexpr int num_bits_per_tma = size(tma_gbasis) * sizeof_bits_v<TmaInternalType>;
|
||||
using Traits = Copy_Traits<CopyOp, cute::C<num_bits_per_tma>, decltype(aux_params)>;
|
||||
using Atom = Copy_Atom<Traits, typename GEngine::value_type>;
|
||||
|
||||
@@ -1105,6 +1182,14 @@ make_tma_copy(CopyOp const& copy_op,
|
||||
CTA_Tiler const& cta_tiler,
|
||||
Cluster_Size const& cluster_size)
|
||||
{
|
||||
if constexpr (cute::is_same_v<CopyOp, SM90_TMA_LOAD_IM2COL> ||
|
||||
cute::is_same_v<CopyOp, SM90_TMA_STORE_IM2COL>) {
|
||||
return make_im2col_tma_copy(copy_op,
|
||||
gtensor,
|
||||
slayout,
|
||||
cta_tiler,
|
||||
cluster_size);
|
||||
} else {
|
||||
auto cta_v_tile = make_identity_layout(shape(gtensor)).compose(cta_tiler);
|
||||
auto cta_t_tile = make_layout(cluster_size);
|
||||
// Prefer TmaInternalType if specified. Fallback to GEngine::value_type
|
||||
@@ -1112,6 +1197,7 @@ make_tma_copy(CopyOp const& copy_op,
|
||||
return detail::make_tma_copy_tiled<TmaType>(copy_op,
|
||||
gtensor, slayout,
|
||||
cta_t_tile, cta_v_tile);
|
||||
}
|
||||
}
|
||||
|
||||
// Explicit defaulting
|
||||
@@ -1179,9 +1265,11 @@ auto
|
||||
tma_partition(Copy_Atom<Args...> const& copy_atom,
|
||||
CtaCoord const& cta_coord,
|
||||
Layout<TShape,TStride> const& cta_layout, // T: CTA coord -> logical multicast id
|
||||
Tensor<SEngine,SLayout> const& stensor, // SMEM Tensor (TMATile, Iter)
|
||||
Tensor<GEngine,GLayout> const& gtensor) // GMEM Tensor (TMATile, Iter)
|
||||
Tensor<SEngine,SLayout> const& stensor, // SMEM Tensor (TMATile, Rest...)
|
||||
Tensor<GEngine,GLayout> const& gtensor) // GMEM Tensor (TMATile, Rest...)
|
||||
{
|
||||
CUTE_STATIC_ASSERT_V(size<0>(stensor) == size<0>(gtensor));
|
||||
|
||||
// Invert the smem to get the largest contiguous vector in the smem layout
|
||||
Layout inv_smem_layout = right_inverse(get_nonswizzle_portion(layout<0>(stensor)));
|
||||
// Scale that up to cover all of the smem_coords
|
||||
@@ -1189,14 +1277,19 @@ tma_partition(Copy_Atom<Args...> const& copy_atom,
|
||||
|
||||
// Factor out the single-instrucion portion
|
||||
Layout tma_layout_v = make_layout(Int<Copy_Atom<Args...>::NumValSrc>{});
|
||||
Layout layout_V = logical_divide(layout_v, tma_layout_v);
|
||||
|
||||
auto layout_V = make_tile(logical_divide(layout_v, tma_layout_v));
|
||||
|
||||
// Append with _ until we cover all Rest... modes
|
||||
auto glayout_V = append<rank_v<decltype(gtensor)>>(layout_V, _);
|
||||
auto slayout_V = append<rank_v<decltype(stensor)>>(layout_V, _);
|
||||
// Transform tile mode and coalesce
|
||||
Tensor gtensor_v = coalesce(gtensor.compose(layout_V, _), Shape<Shape<_1,_1>,_1>{}); // ((TMA,TMA_Iter),Iter)
|
||||
Tensor stensor_v = coalesce(stensor.compose(layout_V, _), Shape<Shape<_1,_1>,_1>{}); // ((TMA,TMA_Iter),Iter)
|
||||
Tensor gtensor_v = coalesce(gtensor.compose(glayout_V), Shape<Shape<_1,_1>>{}); // ((TMA,TMA_Iter), Rest...)
|
||||
Tensor stensor_v = coalesce(stensor.compose(slayout_V), Shape<Shape<_1,_1>>{}); // ((TMA,TMA_Iter), Rest...)
|
||||
|
||||
#if 0
|
||||
if (thread0()) {
|
||||
print("gtensor : "); print(gtensor); print("\n");
|
||||
print("stensor : "); print(stensor); print("\n");
|
||||
print("layout_V : "); print(layout_V); print("\n");
|
||||
print("gtensor_v : "); print(gtensor_v); print("\n");
|
||||
print("stensor_v : "); print(stensor_v); print("\n");
|
||||
@@ -1205,11 +1298,15 @@ tma_partition(Copy_Atom<Args...> const& copy_atom,
|
||||
|
||||
// Restride the cta-into-tma-instr layout
|
||||
Layout tma_layout_t = composition(make_layout(Int<1>{}, shape_div(size(tma_layout_v), cosize(cta_layout))), cta_layout);
|
||||
Layout tma_layout_tv = make_layout(tma_layout_t, tma_layout_v);
|
||||
auto tma_layout_tv = make_tile(make_tile(make_layout(tma_layout_t, tma_layout_v), _));
|
||||
|
||||
// Append with _ until we cover all Rest... modes
|
||||
auto gtma_layout_tv = append<rank_v<decltype(gtensor)>>(tma_layout_tv, _);
|
||||
auto stma_layout_tv = append<rank_v<decltype(stensor)>>(tma_layout_tv, _);
|
||||
|
||||
// Transform TMA mode
|
||||
Tensor gtensor_tv = gtensor_v.compose(make_tile(tma_layout_tv, _), _); // (((Thr,Frg),TMA_Iter),Iter)
|
||||
Tensor stensor_tv = stensor_v.compose(make_tile(tma_layout_tv, _), _); // (((Thr,Frg),TMA_Iter),Iter)
|
||||
Tensor gtensor_tv = gtensor_v.compose(gtma_layout_tv); // (((Thr,Frg),TMA_Iter), Rest...)
|
||||
Tensor stensor_tv = stensor_v.compose(stma_layout_tv); // (((Thr,Frg),TMA_Iter), Rest...)
|
||||
|
||||
#if 0
|
||||
if (thread0()) {
|
||||
@@ -1219,9 +1316,11 @@ tma_partition(Copy_Atom<Args...> const& copy_atom,
|
||||
}
|
||||
#endif
|
||||
|
||||
// Slice and group Frg,TMA_Iter and return
|
||||
auto c = make_coord(make_coord(make_coord(cta_coord, _), _), _);
|
||||
return cute::make_tuple(group_modes<0,2>(gtensor_tv(c)), group_modes<0,2>(stensor_tv(c)));
|
||||
auto c = make_coord(make_coord(make_coord(cta_coord, _), _));
|
||||
auto c_s = append<rank_v<decltype(stensor_tv)>>(c, _);
|
||||
auto c_g = append<rank_v<decltype(gtensor_tv)>>(c, _);
|
||||
|
||||
return cute::make_tuple(group_modes<0,2>(gtensor_tv(c_g)), group_modes<0,2>(stensor_tv(c_s)));
|
||||
}
|
||||
|
||||
} // end namespace cute
|
||||
|
||||
@@ -35,7 +35,6 @@
|
||||
#include <cute/arch/mma.hpp>
|
||||
|
||||
#include <cute/atom/mma_traits.hpp>
|
||||
|
||||
#include <cute/tensor.hpp>
|
||||
#include <cute/util/type_traits.hpp>
|
||||
|
||||
@@ -78,7 +77,7 @@ struct MMA_Atom<MMA_Traits<Args...>>
|
||||
CUTE_HOST_DEVICE
|
||||
auto
|
||||
with(TraitsArgs&&... args) const {
|
||||
auto traits = Traits::with(std::forward<TraitsArgs>(args)...);
|
||||
auto traits = Traits::with(static_cast<TraitsArgs&&>(args)...);
|
||||
return MMA_Atom<decltype(traits)>{traits};
|
||||
}
|
||||
|
||||
@@ -157,7 +156,7 @@ struct MMA_Atom<MMA_Traits<Args...>>
|
||||
// If the intended FrgTypeA is a view (of the current tensor), forward the whole
|
||||
static_assert(is_same<ValTypeA, typename remove_cvref_t<ATensor>::value_type>::value
|
||||
, "Expecting ValTypeA type");
|
||||
return make_tensor<FrgTypeA>(std::forward<ATensor>(atensor));
|
||||
return make_tensor<FrgTypeA>(static_cast<ATensor&&>(atensor));
|
||||
} else {
|
||||
// Else, the intended FrgTypeA is a value type, construct a new tensor with a fragment layout
|
||||
return make_fragment_like<FrgTypeA>(atensor);
|
||||
@@ -179,7 +178,7 @@ struct MMA_Atom<MMA_Traits<Args...>>
|
||||
// If the intended FrgTypeB is a view (of the current tensor), forward the whole
|
||||
static_assert(is_same<ValTypeB, typename remove_cvref_t<BTensor>::value_type>::value
|
||||
, "Expecting ValTypeB type");
|
||||
return make_tensor<FrgTypeB>(std::forward<BTensor>(btensor));
|
||||
return make_tensor<FrgTypeB>(static_cast<BTensor&&>(btensor));
|
||||
} else {
|
||||
// Else, the intended FrgTypeB is a value type, construct a new tensor with a fragment layout
|
||||
return make_fragment_like<FrgTypeB>(btensor);
|
||||
@@ -213,7 +212,7 @@ struct TiledMMA : MMA_Atom
|
||||
|
||||
static_assert( rank_v<AtomLayoutMNK> == 3, "TiledMMA requires rank-3 AtomLayoutMNK");
|
||||
static_assert( rank_v<PermutationMNK> == 3, "TiledMMA requires rank-3 PermutationMNK");
|
||||
static_assert( is_tile<PermutationMNK>::value, "TiledMMA requires independent permutations of MNK.");
|
||||
static_assert( is_tuple<PermutationMNK>::value, "TiledMMA requires independent permutations of MNK.");
|
||||
static_assert(is_static<PermutationMNK>::value, "TiledMMA requires static permutations of MNK.");
|
||||
|
||||
using ThrLayoutVMNK = decltype(tiled_product(AtomThrID{}, AtomLayoutMNK{}));
|
||||
@@ -391,7 +390,7 @@ struct TiledMMA : MMA_Atom
|
||||
} else {
|
||||
return cute::max(core_size, perm_size);
|
||||
}
|
||||
|
||||
|
||||
CUTE_GCC_UNREACHABLE;
|
||||
}
|
||||
|
||||
@@ -517,7 +516,7 @@ struct ThrMMA : TiledMMA
|
||||
auto
|
||||
partition_C(CTensor&& ctensor) const
|
||||
{
|
||||
auto thr_tensor = make_tensor(std::forward<CTensor>(ctensor).data(), this->thrfrg_C(ctensor.layout()));
|
||||
auto thr_tensor = make_tensor(static_cast<CTensor&&>(ctensor).data(), this->thrfrg_C(ctensor.layout()));
|
||||
|
||||
auto thr_vmn = make_coord(get<0>(thr_vmnk_), make_coord(get<1>(thr_vmnk_), get<2>(thr_vmnk_)));
|
||||
return thr_tensor(thr_vmn, make_coord(_, repeat<rank<1,1>(thr_tensor)>(_)));
|
||||
@@ -528,7 +527,7 @@ struct ThrMMA : TiledMMA
|
||||
auto
|
||||
partition_A(ATensor&& atensor) const
|
||||
{
|
||||
auto thr_tensor = make_tensor(std::forward<ATensor>(atensor).data(), this->thrfrg_A(atensor.layout()));
|
||||
auto thr_tensor = make_tensor(static_cast<ATensor&&>(atensor).data(), this->thrfrg_A(atensor.layout()));
|
||||
|
||||
auto thr_vmk = make_coord(get<0>(thr_vmnk_), make_coord(get<1>(thr_vmnk_), get<3>(thr_vmnk_)));
|
||||
return thr_tensor(thr_vmk, make_coord(_, repeat<rank<1,1>(thr_tensor)>(_)));
|
||||
@@ -539,7 +538,7 @@ struct ThrMMA : TiledMMA
|
||||
auto
|
||||
partition_B(BTensor&& btensor) const
|
||||
{
|
||||
auto thr_tensor = make_tensor(std::forward<BTensor>(btensor).data(), this->thrfrg_B(btensor.layout()));
|
||||
auto thr_tensor = make_tensor(static_cast<BTensor&&>(btensor).data(), this->thrfrg_B(btensor.layout()));
|
||||
|
||||
auto thr_vnk = make_coord(get<0>(thr_vmnk_), make_coord(get<2>(thr_vmnk_), get<3>(thr_vmnk_)));
|
||||
return thr_tensor(thr_vnk, make_coord(_, repeat<rank<1,1>(thr_tensor)>(_)));
|
||||
@@ -744,7 +743,15 @@ print(ThrMMA<TiledMMA, ThrVMNK> const& thr_mma)
|
||||
|
||||
template <class... Args>
|
||||
CUTE_HOST_DEVICE
|
||||
auto
|
||||
void
|
||||
print_latex(MMA_Atom<Args...> const& mma_atom)
|
||||
{
|
||||
print_latex(make_tiled_mma(mma_atom));
|
||||
}
|
||||
|
||||
template <class... Args>
|
||||
CUTE_HOST_DEVICE
|
||||
void
|
||||
print_latex(TiledMMA<Args...> const& mma)
|
||||
{
|
||||
auto layout_and_thrid_C = mma.get_layoutC_MN();
|
||||
@@ -764,7 +771,7 @@ print_latex(TiledMMA<Args...> const& mma)
|
||||
layoutB_NK, thrID_B);
|
||||
}
|
||||
|
||||
// MNK MMA Layout to console printer -- 8-value color coded by thread
|
||||
// MNK MMA Layout to console printer
|
||||
template <class LayoutC, class ThrIDC,
|
||||
class LayoutA, class ThrIDA,
|
||||
class LayoutB, class ThrIDB>
|
||||
|
||||
@@ -32,12 +32,8 @@
|
||||
|
||||
#include <cute/arch/mma_sm80.hpp>
|
||||
#include <cute/atom/mma_traits.hpp>
|
||||
|
||||
#include <cute/layout.hpp>
|
||||
|
||||
#include <cute/numeric/integer_subbyte.hpp>
|
||||
|
||||
#include <cutlass/numeric_types.h>
|
||||
#include <cute/numeric/numeric_types.hpp>
|
||||
|
||||
namespace cute
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user