pool3d_fwd_fp16.cpp 4.45 KB
Newer Older
rocking's avatar
rocking committed
1
// SPDX-License-Identifier: MIT
Illia Silin's avatar
Illia Silin committed
2
// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
rocking's avatar
rocking committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

#include <iostream>

#include "ck/ck.hpp"
#include "ck/tensor_operation/gpu/device/tensor_layout.hpp"
#include "ck/utility/reduction_enums.hpp"

#include "pool3d_fwd_common.hpp"

using InDataType      = ck::half_t;
using OutDataType     = ck::half_t;
using ComputeDataType = float;

using IndexDataType = int32_t;

18
#if 1
rocking's avatar
rocking committed
19
20
21
using InLayout  = ck::tensor_layout::convolution::NDHWC;
using OutLayout = ck::tensor_layout::convolution::NDHWC;

22
23
24
25
26
27
28
29
static constexpr bool IsFastestDimReduced = false;
#else
using InLayout  = ck::tensor_layout::convolution::NCDHW;
using OutLayout = ck::tensor_layout::convolution::NCDHW;

static constexpr bool IsFastestDimReduced = true;
#endif

rocking's avatar
rocking committed
30
31
32
#if 1
static constexpr auto ReduceOpId = ck::ReduceTensorOp::MAX;
#else
33
static constexpr auto ReduceOpId          = ck::ReduceTensorOp::AVG;
rocking's avatar
rocking committed
34
35
36
37
38
#endif

static constexpr bool OutputIndex  = false;
static constexpr bool PropagateNan = false;

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using DevicePoolFwdInstance =
    ck::tensor_operation::device::DevicePool3dFwdImpl<InDataType,      // InDataType
                                                      OutDataType,     // OutDataType
                                                      IndexDataType,   // IndexDataType
                                                      ComputeDataType, // ComputeDataType
                                                      ReduceOpId,
                                                      OutputIndex,
                                                      64, // BlockSize
                                                      64, // ReduceMThreadClusterSize
                                                      1,  // ReduceKThreadClusterSize
                                                      1,  // ReduceMThreadSliceSize
                                                      1,  // ReduceKThreadSliceSize
                                                      1,  // InSrcOutDstVectorSize
                                                      IsFastestDimReduced>;

rocking's avatar
rocking committed
54
55
56
57
58
59
int main()
{
    bool do_verification = true;
    bool time_kernel     = false;

    // Pool shape
rocking's avatar
rocking committed
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
    ck::index_t N                 = 2;
    ck::index_t C                 = 32;
    ck::index_t Z                 = 2;
    ck::index_t Y                 = 2;
    ck::index_t X                 = 2;
    ck::index_t Di                = 30;
    ck::index_t Hi                = 30;
    ck::index_t Wi                = 30;
    ck::index_t window_stride_d   = 2;
    ck::index_t window_stride_h   = 2;
    ck::index_t window_stride_w   = 2;
    ck::index_t window_dilation_d = 1;
    ck::index_t window_dilation_h = 1;
    ck::index_t window_dilation_w = 1;
    ck::index_t in_left_pad_d     = 1;
    ck::index_t in_left_pad_h     = 1;
    ck::index_t in_left_pad_w     = 1;
    ck::index_t in_right_pad_d    = 1;
    ck::index_t in_right_pad_h    = 1;
    ck::index_t in_right_pad_w    = 1;
rocking's avatar
rocking committed
80

81
82
    bool pass = pool3d_test<DevicePoolFwdInstance,
                            InDataType,
rocking's avatar
rocking committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                            OutDataType,
                            ComputeDataType,
                            IndexDataType,
                            InLayout,
                            OutLayout,
                            ReduceOpId,
                            PropagateNan,
                            OutputIndex>(do_verification,
                                         time_kernel,
                                         N,
                                         C,
                                         Z,
                                         Y,
                                         X,
                                         Di,
                                         Hi,
                                         Wi,
                                         window_stride_d,
                                         window_stride_h,
                                         window_stride_w,
rocking's avatar
rocking committed
103
104
105
                                         window_dilation_d,
                                         window_dilation_h,
                                         window_dilation_w,
rocking's avatar
rocking committed
106
107
108
109
110
111
112
113
114
                                         in_left_pad_d,
                                         in_left_pad_h,
                                         in_left_pad_w,
                                         in_right_pad_d,
                                         in_right_pad_h,
                                         in_right_pad_w);

    return (pass ? 0 : 1);
}