argmax.cpp 822 Bytes
Newer Older
Shucai Xiao's avatar
Shucai Xiao committed
1
2
3
#include <migraphx/gpu/argmax.hpp>
#include <migraphx/gpu/device/argmax.hpp>
#include <migraphx/gpu/context.hpp>
4
#include <migraphx/tune_axis.hpp>
Shucai Xiao's avatar
Shucai Xiao committed
5
6
7
8
9
10
11
12

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

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

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

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