logsoftmax.cpp 927 Bytes
Newer Older
1
#include <migraphx/gpu/logsoftmax.hpp>
2
#include <migraphx/gpu/device/logsoftmax.hpp>
3
#include <migraphx/op/logsoftmax.hpp>
4
5
#include <migraphx/manage_ptr.hpp>
#include <migraphx/gpu/miopen.hpp>
6
#include <migraphx/tune_axis.hpp>
7
8
9
10
11
12
#include <utility>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

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

Shucai Xiao's avatar
Shucai Xiao committed
19
20
argument
hip_logsoftmax::compute(context& ctx, const shape&, const std::vector<argument>& args) const
21
{
22
    auto n_dim      = args.front().get_shape().lens().size();
23
    auto tuned_axis = tune_axis(n_dim, op.axis, op.name());
24
    device::logsoftmax(ctx.get_stream().get(), args.back(), args.front(), tuned_axis);
25
    return args.back();
26
27
28
29
30
}

} // namespace gpu
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx