layernorm.cpp 1.05 KB
Newer Older
turneram's avatar
turneram committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <migraphx/gpu/layernorm.hpp>
#include <migraphx/gpu/context.hpp>
#include <migraphx/gpu/device/layernorm.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {

shape hip_layernorm::compute_shape(std::vector<shape> inputs) const
{
    std::cout << "compute shape" << std::endl;
    inputs.pop_back();
    return op.normalize_compute_shape(inputs);
}

argument hip_layernorm::compute(context& ctx, const shape&, const std::vector<argument>& args) const
{
    /* if (args.size() == 3)
    {
        auto n_dim      = args.front().get_shape().lens().size();
        auto tuned_axis = tune_axis(n_dim, op.axis, op.name());
        device::layernorm(ctx.get_stream().get(), args.back(), args[0], args[1], args[2], tuned_axis);
    }
    else */
    std::cout << "calling device::ln" << std::endl;
    {
        
        device::layernorm(ctx.get_stream().get(), args.back(), args[0]);
        std::cout << "called device::ln" << std::endl;
    }
    return args.back();
}

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