|
3 | 3 |
|
4 | 4 | #include "utils/ckb_conv_test_configs.hpp" |
5 | 5 | #include "utils/ckb_conv_test_utils.hpp" |
| 6 | +#include "ck_tile/builder/testing/tensor_memory_manager.hpp" |
| 7 | +#include "ck_tile/builder/testing/conv_args.hpp" |
6 | 8 |
|
7 | 9 | namespace { |
8 | 10 |
|
9 | 11 | using namespace ck_tile::builder::test_utils; |
10 | 12 |
|
| 13 | +namespace ckb = ck_tile::builder; |
| 14 | +namespace ckt = ck_tile::builder::test; |
| 15 | + |
11 | 16 | TEST(FwdConvInstances, Create_DeviceGroupedConvFwdDlMultipleD_NHWC_KYXC_NHWK_Instance_2D_FP16_GNHWC) |
12 | 17 | { |
13 | 18 | constexpr ConvSignature FwdConvSignature{.spatial_dim = 2, |
@@ -54,4 +59,104 @@ TEST(FwdConvInstances, |
54 | 59 | {"DeviceGroupedConvFwdDlMultipleD_NHWC_KYXC_NHWK", "256, 128, 128, 16", "Filter1x1Pad0"}); |
55 | 60 | } |
56 | 61 |
|
| 62 | +TEST(FwdConvInstances, Fp16_2D_DL_EndToEndBasic) |
| 63 | +{ |
| 64 | + constexpr ConvSignature signature{.spatial_dim = 2, |
| 65 | + .direction = ConvDirection::FORWARD, |
| 66 | + .layout = GroupConvLayout2D::GNHWC_GKYXC_GNHWK, |
| 67 | + .data_type = DataType::FP16, |
| 68 | + .elementwise_operation = ElementwiseOperation::PASS_THROUGH}; |
| 69 | + |
| 70 | + constexpr auto algorithm = |
| 71 | + ConvAlgorithm_DeviceGroupedConvFwdDlMultipleD_NHWC_KYXC_NHWK{} |
| 72 | + .with_thread_block(FwdThreadBlock_256_128x128x16) |
| 73 | + .with_specializations(ConvFwdSpecialization::DEFAULT, GemmSpecialization::MNKPadding) |
| 74 | + .with_dl_thread_config(DlThreadConfig_16x2x4x4x1) |
| 75 | + .with_dl_thread_cluster(DlThreadCluster_8x2) |
| 76 | + .with_dl_transfer(DlFwdTransfer); |
| 77 | + |
| 78 | + auto args = ckt::ConvArgs<signature>{ |
| 79 | + .lengths = |
| 80 | + { |
| 81 | + .batch_size = 16, |
| 82 | + .groups = 1, |
| 83 | + .input_channels = 32, |
| 84 | + .output_channels = 16, |
| 85 | + .image = |
| 86 | + { |
| 87 | + .width = 56, |
| 88 | + .height = 56, |
| 89 | + }, |
| 90 | + .filter = |
| 91 | + { |
| 92 | + .width = 3, |
| 93 | + .height = 3, |
| 94 | + }, |
| 95 | + }, |
| 96 | + .filter_strides = {.width = 1, .height = 1}, |
| 97 | + .filter_dilation = {.width = 1, .height = 1}, |
| 98 | + .input_left_pad = {.width = 0, .height = 0}, |
| 99 | + .input_right_pad = {.width = 0, .height = 0}, |
| 100 | + }; |
| 101 | + |
| 102 | + auto tmm = ckt::TensorMemoryManager<signature>(args); |
| 103 | + |
| 104 | + auto conv = ConvBuilder<signature, algorithm>::Instance{}; |
| 105 | + |
| 106 | + auto invoker = conv.MakeInvoker(); |
| 107 | + |
| 108 | + const auto input_desc = tmm.input_descriptor; |
| 109 | + const auto weight_desc = tmm.weight_descriptor; |
| 110 | + const auto output_desc = tmm.output_descriptor; |
| 111 | + |
| 112 | + std::array<ck::index_t, 2 + 3> input_lengths; |
| 113 | + std::array<ck::index_t, 2 + 3> input_strides; |
| 114 | + std::array<ck::index_t, 2 + 3> weight_lengths; |
| 115 | + std::array<ck::index_t, 2 + 3> weight_strides; |
| 116 | + std::array<ck::index_t, 2 + 3> output_lengths; |
| 117 | + std::array<ck::index_t, 2 + 3> output_strides; |
| 118 | + std::array<ck::index_t, 2> conv_filter_strides; |
| 119 | + std::array<ck::index_t, 2> conv_filter_dilations; |
| 120 | + std::array<ck::index_t, 2> input_left_pads; |
| 121 | + std::array<ck::index_t, 2> input_right_pads; |
| 122 | + |
| 123 | + auto copy = [](auto& src, auto& dst) { std::copy(src.begin(), src.end(), dst.begin()); }; |
| 124 | + |
| 125 | + copy(input_desc.GetLengths(), input_lengths); |
| 126 | + copy(input_desc.GetStrides(), input_strides); |
| 127 | + copy(weight_desc.GetLengths(), weight_lengths); |
| 128 | + copy(weight_desc.GetStrides(), weight_strides); |
| 129 | + copy(output_desc.GetLengths(), output_lengths); |
| 130 | + copy(output_desc.GetStrides(), output_strides); |
| 131 | + |
| 132 | + copy(tmm.param.conv_filter_strides_, conv_filter_strides); |
| 133 | + copy(tmm.param.conv_filter_dilations_, conv_filter_dilations); |
| 134 | + copy(tmm.param.input_left_pads_, input_left_pads); |
| 135 | + copy(tmm.param.input_right_pads_, input_right_pads); |
| 136 | + |
| 137 | + auto argument = conv.MakeArgument(tmm.input_buf.get(), |
| 138 | + tmm.weight_buf.get(), |
| 139 | + {}, |
| 140 | + tmm.output_buf.get(), |
| 141 | + input_lengths, |
| 142 | + input_strides, |
| 143 | + weight_lengths, |
| 144 | + weight_strides, |
| 145 | + {}, |
| 146 | + {}, |
| 147 | + output_lengths, |
| 148 | + output_strides, |
| 149 | + conv_filter_strides, |
| 150 | + conv_filter_dilations, |
| 151 | + input_left_pads, |
| 152 | + input_right_pads, |
| 153 | + ck::tensor_operation::element_wise::PassThrough{}, |
| 154 | + ck::tensor_operation::element_wise::PassThrough{}, |
| 155 | + ck::tensor_operation::element_wise::PassThrough{}); |
| 156 | + |
| 157 | + ASSERT_THAT(conv.IsSupportedArgument(argument), testing::IsTrue()); |
| 158 | + |
| 159 | + invoker.Run(argument, {}); |
| 160 | +} |
| 161 | + |
57 | 162 | } // namespace |
0 commit comments