device_reduce.hpp 1.71 KB
Newer Older
1
2
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef DEVICE_REDUCE_HPP
#define DEVICE_REDUCE_HPP

#include <vector>
#include <memory>
#include <iostream>

#include "common_header.hpp"
#include "device_base.hpp"
#include "reduction_enums.hpp"

namespace ck {
namespace tensor_operation {
namespace device {

template <typename InElementwiseOperation, typename AccElementwiseOperation>
struct DeviceReduce : public BaseOperator
{
    virtual size_t GetWorkspaceSizeInBytes(const std::vector<int>& inLengths)
    {
        (void)inLengths;

        return (0);
    };

    virtual bool HasFurtherCall() { return (false); };

    virtual std::vector<int> GetWorkspace2dLengths(const BaseArgument* argPtr)
    {
        (void)argPtr;
        return (std::vector<int>{0, 0});
    };

    virtual std::unique_ptr<BaseArgument>
    MakeArgumentPointer(const std::vector<int>& inLengths,
                        const std::vector<int>& inStrides,
                        const std::vector<int>& outLengths,
                        const std::vector<int>& outStrides,
                        float alpha,
                        float beta,
                        const void* in_dev,
                        void* out_dev,
                        void* out_indices_dev,
                        void* workspace_dev,
                        const InElementwiseOperation& inElementwiseOp,
                        const AccElementwiseOperation& accElementwiseOp) = 0;

    virtual std::unique_ptr<BaseInvoker> MakeInvokerPointer() = 0;
};

template <typename InElementwiseOperation, typename AccElementwiseOperation>
using DeviceReducePtr =
    std::unique_ptr<DeviceReduce<InElementwiseOperation, AccElementwiseOperation>>;

} // namespace device
} // namespace tensor_operation
} // namespace ck
#endif