softmax.cpp 821 Bytes
Newer Older
Paul's avatar
Paul committed
1
#include <migraphx/gpu/softmax.hpp>
Khalique's avatar
Khalique committed
2
#include <migraphx/gpu/device/softmax.hpp>
Khalique's avatar
Khalique committed
3
#include <migraphx/gpu/context.hpp>
4
#include <migraphx/tune_axis.hpp>
5

Paul's avatar
Paul committed
6
namespace migraphx {
Paul's avatar
Paul committed
7
inline namespace MIGRAPHX_INLINE_NS {
8
9
namespace gpu {

Khalique's avatar
Khalique committed
10
shape hip_softmax::compute_shape(const std::vector<shape>& inputs) const
11
12
{
    check_shapes{inputs, *this}.has(2).standard();
Shucai Xiao's avatar
Shucai Xiao committed
13
    return op.normalize_compute_shape({inputs.at(0)});
14
15
}

Shucai Xiao's avatar
Shucai Xiao committed
16
argument hip_softmax::compute(context& ctx, const shape&, const std::vector<argument>& args) const
17
{
18
    auto n_dim      = args.front().get_shape().lens().size();
19
    auto tuned_axis = tune_axis(n_dim, op.axis, op.name());
20
    device::softmax(ctx.get_stream().get(), args.back(), args.front(), tuned_axis);
21
    return args.back();
22
23
24
}

} // namespace gpu
Paul's avatar
Paul committed
25
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
26
} // namespace migraphx