pool3d_fwd_fp16.cpp 4.15 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
18
19
20
21
22
23
24
25
26
27
28
29

#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;

using InLayout  = ck::tensor_layout::convolution::NDHWC;
using OutLayout = ck::tensor_layout::convolution::NDHWC;

#if 1
static constexpr auto ReduceOpId = ck::ReduceTensorOp::MAX;
#else
static constexpr auto ReduceOpId = ck::ReduceTensorOp::AVG;
#endif

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

rocking's avatar
rocking committed
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using DevicePoolFwdInstance =
    ck::tensor_operation::device::DevicePool3dFwd_NDHWC_NDHWC<InDataType,
                                                              OutDataType,
                                                              IndexDataType,
                                                              ComputeDataType,
                                                              ReduceOpId,
                                                              OutputIndex,
                                                              64, // BlockSize
                                                              64, // ReduceMThreadClusterSize
                                                              1,  // ReduceKThreadClusterSize
                                                              1,  // ReduceMThreadSliceSize
                                                              1,  // ReduceKThreadSliceSize
                                                              1>; // InSrcOutDstVectorSize

rocking's avatar
rocking committed
44
45
46
47
48
49
int main()
{
    bool do_verification = true;
    bool time_kernel     = false;

    // Pool shape
rocking's avatar
rocking committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
    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
70

rocking's avatar
rocking committed
71
72
    bool pass = pool3d_test<DevicePoolFwdInstance,
                            InDataType,
rocking's avatar
rocking committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
                            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
93
94
95
                                         window_dilation_d,
                                         window_dilation_h,
                                         window_dilation_w,
rocking's avatar
rocking committed
96
97
98
99
100
101
102
103
104
                                         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);
}