avgpool3d_bwd_fp16.cpp 2.41 KB
Newer Older
rocking's avatar
rocking committed
1
2
3
4
5
6
// SPDX-License-Identifier: MIT
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.

#include <iostream>

#include "ck/ck.hpp"
rocking's avatar
rocking committed
7
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
rocking's avatar
rocking committed
8
#include "ck/tensor_operation/gpu/device/impl/device_avgpool3d_bwd_impl.hpp"
rocking's avatar
rocking committed
9

rocking's avatar
rocking committed
10
#include "avgpool3d_bwd_common.hpp"
rocking's avatar
rocking committed
11

rocking's avatar
rocking committed
12
13
using DOutDataType    = ck::half_t;
using DInDataType     = ck::half_t;
rocking's avatar
rocking committed
14
using ComputeDataType = float;
rocking's avatar
rocking committed
15

rocking's avatar
rocking committed
16
#if 1
rocking's avatar
rocking committed
17
18
19
using DOutLayout = ck::tensor_layout::convolution::NDHWC;
using DInLayout  = ck::tensor_layout::convolution::NDHWC;

rocking's avatar
rocking committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
static constexpr bool IsFastestDimReduced = false;
#else
using DOutLayout = ck::tensor_layout::convolution::NCDHW;
using DInLayout  = ck::tensor_layout::convolution::NCDHW;

static constexpr bool IsFastestDimReduced = true;
#endif

using DevicePoolBwdInstance =
    ck::tensor_operation::device::DeviceAvgPool3dBwdImpl<3,
                                                         DOutDataType,
                                                         DInDataType,
                                                         ComputeDataType, // ComputeDataType
                                                         64,              // BlockSize
                                                         64, // ReduceMThreadClusterSize
                                                         1,  // ReduceKThreadClusterSize
                                                         1,  // ReduceMThreadSliceSize
                                                         1,  // ReduceKThreadSliceSize
                                                         1,  // InSrcOutDstVectorSize
                                                         IsFastestDimReduced>;
rocking's avatar
rocking committed
40
41
42
43
44

int main()
{
    std::vector<ck::index_t> window_lengths    = {5, 5, 5};
    std::vector<ck::index_t> window_strides    = {2, 2, 2};
rocking's avatar
rocking committed
45
    std::vector<ck::index_t> window_dilations  = {2, 2, 2};
rocking's avatar
rocking committed
46
47
48
49
50
51
52
53
54
    std::vector<ck::index_t> dinput_left_pads  = {0, 0, 0};
    std::vector<ck::index_t> dinput_right_pads = {0, 0, 0};

    ck::index_t N  = 1;
    ck::index_t C  = 16;
    ck::index_t Di = 40;
    ck::index_t Hi = 40;
    ck::index_t Wi = 40;

rocking's avatar
rocking committed
55
56
57
58
59
60
61
62
63
64
65
66
67
    pool3d_bwd_test<DevicePoolBwdInstance, DOutDataType, DInDataType, DOutLayout, DInLayout>(
        true,
        false,
        N,
        C,
        Di,
        Hi,
        Wi,
        window_lengths,
        window_strides,
        window_dilations,
        dinput_left_pads,
        dinput_right_pads);
rocking's avatar
rocking committed
68
}