pooling.cpp 1.14 KB
Newer Older
Paul's avatar
Paul committed
1
#include <migraphx/gpu/pooling.hpp>
Paul's avatar
Paul committed
2
#include <migraphx/gpu/context.hpp>
wsttiger's avatar
wsttiger committed
3

Paul's avatar
Paul committed
4
namespace migraphx {
Paul's avatar
Paul committed
5
inline namespace MIGRAPHX_INLINE_NS {
wsttiger's avatar
wsttiger committed
6
7
8
9
10
11
12
namespace gpu {

shape miopen_pooling::compute_shape(const std::vector<shape>& inputs) const
{
    check_shapes{inputs, *this}.has(2).standard();
    return op.compute_shape({inputs.at(0)});
}
wsttiger's avatar
wsttiger committed
13
14
15
argument miopen_pooling::compute(context& ctx,
                                 const shape& output_shape,
                                 const std::vector<argument>& args) const
wsttiger's avatar
wsttiger committed
16
17
18
19
{
    auto x_desc = make_tensor(args[0].get_shape());
    auto y_desc = make_tensor(output_shape);

Paul's avatar
Paul committed
20
    float alpha = 1;
Paul's avatar
Paul committed
21
    float beta  = 0;
wsttiger's avatar
wsttiger committed
22

Paul's avatar
Paul committed
23
    miopenPoolingForward(ctx.get_stream().get_miopen(),
wsttiger's avatar
wsttiger committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
                         pd.get(),
                         &alpha,
                         x_desc.get(),
                         args[0].implicit(),
                         &beta,
                         y_desc.get(),
                         args[1].implicit(),
                         false,
                         nullptr,
                         0);

    return args[1];
}

} // namespace gpu
Paul's avatar
Paul committed
39
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
40
} // namespace migraphx