softmax.cpp 782 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

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

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

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

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