mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-20 21:09:08 +00:00
Conv3d new (#94)
* conv3d compiles but has memory error
* conv3d works
* fix performance issue by using __builtin_amdgc_readfirstlane
* change MakeBlock2CTileMap to MakeDefaultBlock2CTileMap; change c_blockid_to* to cblockid_to*
* clang-format
* remove CK_EXPERIMENTAL_PASS_TENSOR_DECRIPTOR_BY_*; moved wrapper into DeviceConv3d
* format
* remove useless marc
* add comment
Co-authored-by: Chao Liu <chao.liu2@amd.com>
[ROCm/composable_kernel commit: 6dfb92bbef]
This commit is contained in:
@@ -130,13 +130,13 @@ int main(int argc, char* argv[])
|
||||
const ck::index_t Ho = (Hi + in_left_pad_h + in_right_pad_h - YEff) / conv_stride_h + 1;
|
||||
const ck::index_t Wo = (Wi + in_left_pad_w + in_right_pad_w - XEff) / conv_stride_w + 1;
|
||||
|
||||
const std::vector<ck::index_t> input_spatial_lengths{{Hi, Wi}};
|
||||
const std::vector<ck::index_t> filter_spatial_lengths{{Y, X}};
|
||||
const std::vector<ck::index_t> output_spatial_lengths{{Ho, Wo}};
|
||||
const std::vector<ck::index_t> conv_filter_strides{{conv_stride_h, conv_stride_w}};
|
||||
const std::vector<ck::index_t> conv_filter_dilations{{conv_dilation_h, conv_dilation_w}};
|
||||
const std::vector<ck::index_t> input_left_pads{{in_left_pad_h, in_left_pad_w}};
|
||||
const std::vector<ck::index_t> input_right_pads{{in_right_pad_h, in_right_pad_w}};
|
||||
const std::vector<ck::index_t> input_spatial_lengths{Hi, Wi};
|
||||
const std::vector<ck::index_t> filter_spatial_lengths{Y, X};
|
||||
const std::vector<ck::index_t> output_spatial_lengths{Ho, Wo};
|
||||
const std::vector<ck::index_t> conv_filter_strides{conv_stride_h, conv_stride_w};
|
||||
const std::vector<ck::index_t> conv_filter_dilations{conv_dilation_h, conv_dilation_w};
|
||||
const std::vector<ck::index_t> input_left_pads{in_left_pad_h, in_left_pad_w};
|
||||
const std::vector<ck::index_t> input_right_pads{in_right_pad_h, in_right_pad_w};
|
||||
|
||||
auto f_host_tensor_descriptor =
|
||||
[](std::size_t N_, std::size_t C_, std::size_t H, std::size_t W) {
|
||||
|
||||
@@ -41,6 +41,19 @@ gpu_naive_division(int32_t divisor, const int32_t* p_dividend, int32_t* p_result
|
||||
}
|
||||
}
|
||||
|
||||
__host__ void cpu_magic_number_division(uint32_t magic_multiplier,
|
||||
uint32_t magic_shift,
|
||||
const int32_t* p_dividend,
|
||||
int32_t* p_result,
|
||||
uint64_t num)
|
||||
{
|
||||
for(uint64_t data_id = 0; data_id < num; ++data_id)
|
||||
{
|
||||
p_result[data_id] =
|
||||
ck::MagicDivision::DoMagicDivision(p_dividend[data_id], magic_multiplier, magic_shift);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T check_error(const std::vector<T>& ref, const std::vector<T>& result)
|
||||
{
|
||||
@@ -90,6 +103,7 @@ int main(int, char*[])
|
||||
|
||||
std::vector<int32_t> naive_result_host(num_dividend);
|
||||
std::vector<int32_t> magic_result_host(num_dividend);
|
||||
std::vector<int32_t> magic_result_host2(num_dividend);
|
||||
|
||||
dividends_dev_buf.ToDevice(dividends_host.data());
|
||||
|
||||
@@ -128,6 +142,20 @@ int main(int, char*[])
|
||||
pass = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
cpu_magic_number_division(magic_multiplier,
|
||||
magic_shift,
|
||||
dividends_host.data(),
|
||||
magic_result_host2.data(),
|
||||
num_dividend);
|
||||
|
||||
max_diff = check_error(naive_result_host, magic_result_host2);
|
||||
|
||||
if(max_diff != 0)
|
||||
{
|
||||
pass = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(pass)
|
||||
|
||||
Reference in New Issue
Block a user