device_reduce.hpp Source File

device_reduce.hpp Source File#

Composable Kernel: device_reduce.hpp Source File
device_reduce.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// Copyright (c) 2018-2023, Advanced Micro Devices, Inc. All rights reserved.
3
4#pragma once
5
6#include <array>
7#include <memory>
8
9#include "ck/ck.hpp"
11
12namespace ck {
13namespace tensor_operation {
14namespace device {
15
16template <typename InDataType,
17 typename AccDataType,
18 typename OutDataType,
19 index_t Rank,
20 index_t NumReduceDim,
21 typename ReduceOperation,
22 typename InElementwiseOperation,
23 typename AccElementwiseOperation,
24 bool PropagateNan,
25 bool OutputIndex>
27{
28 static constexpr index_t NumOutDim = (Rank - NumReduceDim == 0) ? 1 : Rank - NumReduceDim;
29
30 virtual std::unique_ptr<BaseArgument>
31 MakeArgumentPointer(const std::array<index_t, Rank> inLengths,
32 const std::array<index_t, Rank> inStrides,
33 const std::array<index_t, NumOutDim> outLengths,
34 const std::array<index_t, NumOutDim> outStrides,
35 const std::array<int, NumReduceDim> reduceDims,
36 double alpha,
37 double beta,
38 const void* in_dev,
39 const void* in_index_dev,
40 void* out_dev,
41 void* out_index_dev,
42 const InElementwiseOperation in_elementwise_op,
43 const AccElementwiseOperation acc_elementwise_op) = 0;
44
45 virtual std::unique_ptr<BaseInvoker> MakeInvokerPointer() = 0;
46};
47
48template <typename InDataType,
49 typename AccDataType,
50 typename OutDataType,
51 index_t Rank,
52 index_t NumReduceDim,
53 typename ReduceOperation,
54 typename InElementwiseOperation,
55 typename AccElementwiseOperation,
56 bool PropagateNan,
57 bool OutputIndex>
58using DeviceReducePtr = std::unique_ptr<DeviceReduce<InDataType,
59 AccDataType,
60 OutDataType,
61 Rank,
62 NumReduceDim,
63 ReduceOperation,
64 InElementwiseOperation,
65 AccElementwiseOperation,
66 PropagateNan,
67 OutputIndex>>;
68
69} // namespace device
70} // namespace tensor_operation
71} // namespace ck
Definition convolution_backward_data_specialization.hpp:8
std::unique_ptr< DeviceReduce< InDataType, AccDataType, OutDataType, Rank, NumReduceDim, ReduceOperation, InElementwiseOperation, AccElementwiseOperation, PropagateNan, OutputIndex > > DeviceReducePtr
Definition device_reduce.hpp:58
Definition convolution_backward_data_specialization.hpp:7
Definition ck.hpp:268
int32_t index_t
Definition ck.hpp:299
Definition device_reduce.hpp:27
virtual std::unique_ptr< BaseArgument > MakeArgumentPointer(const std::array< index_t, Rank > inLengths, const std::array< index_t, Rank > inStrides, const std::array< index_t, NumOutDim > outLengths, const std::array< index_t, NumOutDim > outStrides, const std::array< int, NumReduceDim > reduceDims, double alpha, double beta, const void *in_dev, const void *in_index_dev, void *out_dev, void *out_index_dev, const InElementwiseOperation in_elementwise_op, const AccElementwiseOperation acc_elementwise_op)=0
static constexpr index_t NumOutDim
Definition device_reduce.hpp:28
virtual std::unique_ptr< BaseInvoker > MakeInvokerPointer()=0