fMHA: Sync FW with xFormers (#828)
* fMHA: Add support for bias+dropout in FW * Remove 'getMaximumSharedMemoryPerBlockKb' * fix comments --------- Co-authored-by: danthe3rd <danthe3rd> Co-authored-by: Haicheng Wu <haichengw@nvidia.com>
This commit is contained in:
co-authored by
danthe3rd <danthe3rd>
Haicheng Wu
parent
9cdbe33570
commit
f303889ed9
@@ -50,12 +50,17 @@
|
||||
#if 1
|
||||
#define PRINT_WARP_ID 0
|
||||
#define PRINT_LANE_ID 0
|
||||
#define PRINT_T0_L0(msg, ...) \
|
||||
#define PRINT_B0_T0(msg, ...) \
|
||||
if (blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0 && \
|
||||
threadIdx.x == PRINT_LANE_ID && threadIdx.y == PRINT_WARP_ID && \
|
||||
threadIdx.z == 0) { \
|
||||
printf(msg "\n", ##__VA_ARGS__); \
|
||||
}
|
||||
#define PRINT_T0(msg, ...) \
|
||||
if (threadIdx.x == PRINT_LANE_ID && threadIdx.y == PRINT_WARP_ID && \
|
||||
threadIdx.z == 0) { \
|
||||
printf(msg "\n", ##__VA_ARGS__); \
|
||||
}
|
||||
#define PRINT_TX_LX(msg, ...) \
|
||||
for (int bx = 0; bx < gridDim.x; ++bx) { \
|
||||
for (int by = 0; by < gridDim.y; ++by) { \
|
||||
@@ -84,7 +89,7 @@
|
||||
} \
|
||||
}
|
||||
#else
|
||||
#define PRINT_T0_L0
|
||||
#define PRINT_B0_T0
|
||||
#define PRINT_TX_LX
|
||||
#endif
|
||||
|
||||
@@ -124,7 +129,7 @@ constexpr __string_view __get_type_name() {
|
||||
|
||||
// Print a given array
|
||||
#define PRINT_ACCUM8_T0_L0_START(name, accum, start) \
|
||||
PRINT_T0_L0( \
|
||||
PRINT_B0_T0( \
|
||||
"%s[%d:%d] - {%f, %f, %f, %f, %f, %f, %f, %f}", \
|
||||
name, \
|
||||
int(start), \
|
||||
@@ -141,7 +146,7 @@ constexpr __string_view __get_type_name() {
|
||||
#define PRINT_FRAG_T0_L0(name, frag) \
|
||||
{ \
|
||||
auto typeStr = __get_type_name<decltype(frag)>(); \
|
||||
PRINT_T0_L0("printing %s (%s)", name, typeStr.data); \
|
||||
PRINT_B0_T0("printing %s (%s)", name, typeStr.data); \
|
||||
for (int _start = 0; _start < frag.size(); _start += 8) { \
|
||||
PRINT_ACCUM8_T0_L0_START(" ", frag, _start); \
|
||||
} \
|
||||
@@ -150,7 +155,7 @@ constexpr __string_view __get_type_name() {
|
||||
}
|
||||
#define PRINT_ARRAY_T0_L0_INCR(name, array, length, incr) \
|
||||
{ \
|
||||
PRINT_T0_L0("printing %s (len=%d)", name, int(length)); \
|
||||
PRINT_B0_T0("printing %s (len=%d)", name, int(length)); \
|
||||
for (int _start = 0; _start < length; _start += incr) { \
|
||||
PRINT_ACCUM8_T0_L0_START(" ", array, _start); \
|
||||
} \
|
||||
@@ -160,7 +165,7 @@ constexpr __string_view __get_type_name() {
|
||||
|
||||
// Print a 4x4 matrix
|
||||
#define PRINT_TENSOR4x4_T0_L0_START(name, ref, start_x, start_y) \
|
||||
PRINT_T0_L0( \
|
||||
PRINT_B0_T0( \
|
||||
"%s[%d:%d, %d:%d]:\n %f, %f, %f, %f\n %f, %f, %f, %f\n %f, %f, %f, %f\n %f, %f, %f, %f", \
|
||||
name, \
|
||||
int(start_x), \
|
||||
@@ -187,9 +192,43 @@ constexpr __string_view __get_type_name() {
|
||||
PRINT_TENSOR4x4_T0_L0_START(name, ref, 0, 0)
|
||||
|
||||
#define PRINT_PROBLEM_SIZE(name, ps) \
|
||||
PRINT_T0_L0( \
|
||||
PRINT_B0_T0( \
|
||||
"%s.problem_size: {.m=%d, .n=%d, .k=%d}", \
|
||||
name, \
|
||||
int(ps.m()), \
|
||||
int(ps.n()), \
|
||||
int(ps.k()))
|
||||
|
||||
template <typename LambdaIterator, typename LaneOffsetT, typename AccumT>
|
||||
CUTLASS_DEVICE void print_warp_accum(
|
||||
AccumT accum,
|
||||
LaneOffsetT lane_offset,
|
||||
int32_t num_rows,
|
||||
int32_t num_cols) {
|
||||
bool is_main = blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0 &&
|
||||
threadIdx.x == 0 && threadIdx.y == 0 && threadIdx.z == 0;
|
||||
for (int row = 0; row < num_rows; ++row) {
|
||||
for (int col = 0; col < num_cols; ++col) {
|
||||
if (col % 32 == 0) {
|
||||
if (is_main) {
|
||||
printf("\nmat[%3d, %3d:%3d]", row, col, col + 32);
|
||||
}
|
||||
__syncthreads();
|
||||
}
|
||||
LambdaIterator::iterateRows(
|
||||
lane_offset,
|
||||
[&](int accum_m) {},
|
||||
[&](int accum_m, int accum_n, int idx) {
|
||||
if (row == accum_m && col == accum_n &&
|
||||
(blockIdx.x == 0 && blockIdx.y == 0 && blockIdx.z == 0)) {
|
||||
printf(" %6.1f", float(accum[idx]));
|
||||
}
|
||||
},
|
||||
[&](int accum_m) {});
|
||||
__syncthreads();
|
||||
}
|
||||
if (is_main) {
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user