co-authored by
Aniket Shivam
parent
ca23ff7924
commit
b72cbf957d
@@ -684,6 +684,154 @@ struct TestbedConv2dProblemSizes {
|
||||
|
||||
};
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
/// Structure TestbedGroupConv2dProblemSizes initializes and holds group conv default and
|
||||
/// important network sizes
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
struct TestbedGroupConv2dProblemSizes {
|
||||
|
||||
//
|
||||
// Data members
|
||||
//
|
||||
int threadblock_n;
|
||||
int threadblock_k;
|
||||
int minimum_channel_size;
|
||||
|
||||
Conv2dProblemVector default_single_group_sizes;
|
||||
Conv2dProblemVector default_multiple_group_sizes;
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
/// Default ctor
|
||||
TestbedGroupConv2dProblemSizes(
|
||||
int threadblock_n_,
|
||||
int threadblock_k_,
|
||||
int minimum_channel_size_ = 64)
|
||||
: threadblock_n (threadblock_n_),
|
||||
threadblock_k (threadblock_k_),
|
||||
minimum_channel_size (minimum_channel_size_) {
|
||||
initialize_group_conv2d_default_sizes();
|
||||
filter_all();
|
||||
}
|
||||
|
||||
/// Eliminates some illegal cases
|
||||
void filter_all() {
|
||||
|
||||
Conv2dProblemVector *problems_vectors[] = {
|
||||
&default_single_group_sizes,
|
||||
&default_multiple_group_sizes
|
||||
};
|
||||
|
||||
for (Conv2dProblemVector *problems : problems_vectors) {
|
||||
Conv2dProblemVector filtered;
|
||||
|
||||
for (cutlass::conv::Conv2dProblemSize const & problem : *problems) {
|
||||
if (!((problem.C / problem.groups) % minimum_channel_size)) {
|
||||
filtered.push_back(problem);
|
||||
}
|
||||
}
|
||||
|
||||
*problems = filtered;
|
||||
}
|
||||
}
|
||||
|
||||
// Add a few standard convolution problem sizes
|
||||
void initialize_group_conv2d_default_sizes() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// One group calculated by one or multiple CTAs: k_per_group % CTA::N = 0
|
||||
// One CTA calculates a single group
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
for (int cta_per_group_k = 1; cta_per_group_k < 4; ++cta_per_group_k) {
|
||||
// groups = 2, 3, 4
|
||||
for (int groups = 2; groups < 5; ++groups) {
|
||||
|
||||
int conv_k = cta_per_group_k * threadblock_n * groups;
|
||||
default_single_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k * 2 * groups}, // input size (NHWC)
|
||||
{conv_k, 3, 3, threadblock_k * 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
groups // groups
|
||||
));
|
||||
|
||||
} // loop groups
|
||||
} // loop cta_per_group_k
|
||||
|
||||
// Partial gemm_k: k_per_group == CTA::N && channels_per_group < CTA::K
|
||||
default_single_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k}, // input size (NHWC)
|
||||
{threadblock_n * 2, 3, 3, threadblock_k / 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
2 // groups
|
||||
));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// One CTA calculate multiple groups: CTA::N % k_per_group = 0
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// 2 groups per CTA
|
||||
default_multiple_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k * 4}, // input size (NHWC)
|
||||
{threadblock_n, 3, 3, threadblock_k * 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
2 // groups
|
||||
));
|
||||
|
||||
// 2 groups per CTA and partial gemm_k
|
||||
default_multiple_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k}, // input size (NHWC)
|
||||
{threadblock_n, 3, 3, threadblock_k / 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
2 // groups
|
||||
));
|
||||
|
||||
// 4 groups per CTA
|
||||
default_multiple_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k * 8}, // input size (NHWC)
|
||||
{threadblock_n / 2, 3, 3, threadblock_k * 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
4 // groups
|
||||
));
|
||||
|
||||
// 4 groups per CTA and partial gemm_k
|
||||
default_multiple_group_sizes.push_back(cutlass::conv::Conv2dProblemSize(
|
||||
{1, 8, 8, threadblock_k * 2}, // input size (NHWC)
|
||||
{threadblock_n / 2, 3, 3, threadblock_k / 2}, // filter size (KRSC)
|
||||
{1, 1, 1, 1}, // padding (pad_h, _, pad_w, _)
|
||||
{1, 1}, // stride (stride_h, stride_w)
|
||||
{1, 1}, // dilation (dilation_h, dilation_w)
|
||||
cutlass::conv::Mode::kCrossCorrelation,
|
||||
1, // split_k_slices
|
||||
4 // groups
|
||||
));
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
} // namespace device
|
||||
} // namespace conv
|
||||
} // namespace test
|
||||
|
||||
Reference in New Issue
Block a user