22#include "group/reduction/reduction.hpp"
29template <
typename dtype_acc_,
typename tile_shape_>
40 : sqrt_dk_inv(sqrt_dk_inv_) {}
46 static constexpr uint32_t sg_tile_m = tile_shape::sg_tile_size_y;
47 static constexpr uint32_t sg_tile_n = tile_shape::sg_tile_size_x;
48 static constexpr uint32_t wg_size_x = tile_shape::wg_size_x;
49 static constexpr uint32_t wg_size_y = tile_shape::wg_size_y;
57 struct get_barrier_count {
58 static constexpr uint32_t count = (wg_size_x > 1) ? wg_size_y : 0;
62 static constexpr uint32_t size = (wg_size_x > 1)
63 ? wg_size_y * wg_size_x * sg_tile_m *
sizeof(
dtype_acc)
67 template <
typename matAcc_t>
69 [[maybe_unused]] [[maybe_unused]] [[maybe_unused]] [[maybe_unused]] [[maybe_unused]] [[maybe_unused]] [[maybe_unused]]
coord_t
71 const arguments_t &args, uint32_t slm_base = 0,
72 uint32_t nbarrier_base = 0) {
73 static_assert(std::is_same<typename matAcc_t::dtype, dtype_acc>::value,
74 "matAcc dtype_acc should match with dtype_acc");
75 int32_t sg_idx = g.get_id() % wg_size_x;
76 int32_t sg_idy = g.get_id() / wg_size_x;
77 uint32_t nbarrier_id = nbarrier_base + sg_idy;
78 uint32_t slm_base_addr
79 = slm_base + sg_idy * wg_size_x * sg_tile_m *
sizeof(
dtype_acc);
87 if constexpr (wg_size_x > 1) { nbarrier.arrive(); }
88 subgroup::tile_broadcast_op<subgroup::tile_minus, matAcc_t>(
90 matAcc.reg = matAcc.reg * args.sqrt_dk_inv;
91 matAcc.reg = xetla_exp<dtype_acc>(matAcc.reg);
96 if constexpr (wg_size_x > 1) { nbarrier.wait(); }
98 subgroup::tile_broadcast_op<subgroup::tile_div, matAcc_t>(
__XETLA_API KERNEL_FUNC void operator()(work_group_t &g, matAcc_t &matAcc, coord_t coord, const arguments_t &args, uint32_t slm_base=0, uint32_t nbarrier_base=0)
Definition softmax_fwd_xe.hpp:68
tile_shape_ tile_shape
Definition softmax_fwd_xe.hpp:33
dtype_acc_ dtype_acc
Definition softmax_fwd_xe.hpp:34
#define __XETLA_API
Definition common.hpp:43
__ESIMD_NS::simd< native_type_t< Ty >, N > xetla_vector
wrapper for xetla_vector.
Definition base_types.hpp:149
#define KERNEL_FUNC
KERNEL_FUNC macro.
Definition common.hpp:39
Definition limitation.hpp:607
__XETLA_API std::enable_if_t<(dim==1), xetla_vector< dtype_out, mat_t::tile_size_y > > tile_reduce(mat_t &src)
Definition reduction.hpp:33
gpu_arch
Definition common.hpp:73
This is the group reduction.
Definition reduction_api.hpp:36
Definition softmax_policy.hpp:27
dtype_acc sqrt_dk_inv
Definition softmax_fwd_xe.hpp:37
arguments_t(dtype_acc sqrt_dk_inv_)
Definition softmax_fwd_xe.hpp:39
Definition memory_descriptor.hpp:30
Definition memory_descriptor.hpp:28
Define a workgroup scope for a specific problem shape.
Definition work_group.hpp:34
xetla nbarrier definition API.
Definition raw_send_nbarrier.hpp:43
__XETLA_API void init_nbarrier(uint8_t nbarrier_id, nbarrier_role role=nbarrier_role::producer_consumer)
Definition raw_send_nbarrier.hpp:55