This commit is contained in:
fsx950223
2025-04-08 05:23:00 +00:00
parent 74096bebe0
commit b000f23356
2 changed files with 14 additions and 19 deletions

View File

@@ -36,20 +36,20 @@ auto get_elimit<ck_tile::int8_t>()
int main()
{
static constexpr ck_tile::index_t Repeat_M_ = 1;
static constexpr ck_tile::index_t Repeat_M_ = 8;
static constexpr ck_tile::index_t Repeat_N_ = 1;
static constexpr ck_tile::index_t ThreadPerBlock_M_ = 4;
static constexpr ck_tile::index_t ThreadPerBlock_M_ = 8;
static constexpr ck_tile::index_t ThreadPerBlock_N_ = 64;
static constexpr ck_tile::index_t Vector_N_ = 2;
static constexpr ck_tile::index_t Vector_N_ = 1;
static constexpr bool is_warp_per_row = ThreadPerBlock_N_ <= warpSize;
static_assert((ThreadPerBlock_M_ * ThreadPerBlock_N_) % warpSize == 0);
static constexpr ck_tile::index_t total_warps =
(ThreadPerBlock_M_ * ThreadPerBlock_N_) / warpSize;
// num of warps along mreference_static_per_tensor_quantization2d
// std::cout<<"total_warps: "<<total_warps<<std::endl;
// num of warps along m
static constexpr ck_tile::index_t BlockWarps_M = []() {
if constexpr(is_warp_per_row)
{
@@ -107,9 +107,9 @@ int main()
using Kernel = ck_tile::PerTensorQuant<Pipeline>;
int m = 256;
int n = 256;
int x_stride = 256;
int m = 64;
int n = 64;
int x_stride = 64;
ck_tile::HostTensor<XDataType> x_host({m, n}, {x_stride, 1});
ck_tile::HostTensor<ScaleDataType> scale_host({1}, {1});
@@ -144,7 +144,7 @@ int main()
scale_buf.FromDevice(scale_host.data());
ck_tile::reference_per_tensor_quantization2d<XDataType, ScaleDataType, QXDataType>(
x_host, scale_host, qx_host_ref);
// std::cout<<scale_host(0)<<std::endl;
qx_buf.FromDevice(qx_host_dev.data());
auto [rtol, atol] = get_elimit<QXDataType>();

View File

@@ -9,7 +9,6 @@
#include <type_traits>
namespace ck_tile {
template <typename Problem_, typename Policy_ = PerTensorQuantPipelineDefaultPolicy>
struct StaticPerTensorQuantPipeline
{
@@ -92,7 +91,7 @@ struct DynamicPerTensorQuantPipeline
{
auto x_window =
make_tile_window(x_window_, Policy::template MakeXBlockTileDistribution<Problem>());
auto origin = x_window.get_window_origin();
static constexpr index_t Block_N = Problem::BlockShape::Block_N;
index_t num_n_tile_iteration =
__builtin_amdgcn_readfirstlane(integer_divide_ceil(row_size, Block_N));
@@ -130,12 +129,8 @@ struct DynamicPerTensorQuantPipeline
block_reduce2d_cross_warp_sync(absmax, smem, reduce_max_func);
*scale = absmax.get_thread_buffer()[0] / ck_tile::numeric<QXDataType>::max();
ck_tile::index_t stride_to_right_most_window =
row_size % Block_N == 0 ? row_size - Block_N : row_size - row_size % Block_N;
move_tile_window(x_window, {0, -Block_N});
move_tile_window(qx_window, {0, stride_to_right_most_window});
for(int iN = __builtin_amdgcn_readfirstlane(0); iN < num_n_tile_iteration; ++iN)
{
x_window.set_window_origin(origin);
for(int iN = __builtin_amdgcn_readfirstlane(0); iN < num_n_tile_iteration; ++iN){
const auto x = load_tile(x_window);
const auto qx = tile_elementwise_in(
[&](const auto& a) {
@@ -143,8 +138,8 @@ struct DynamicPerTensorQuantPipeline
},
x);
store_tile(qx_window, qx);
move_tile_window(x_window, {0, -Block_N});
move_tile_window(qx_window, {0, -Block_N});
move_tile_window(x_window, {0, Block_N});
move_tile_window(qx_window, {0, Block_N});
}
}
};