concat.cpp 1.12 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
#include <migraph/gpu/concat.hpp>
#include <migraph/operators.hpp>
#include <migraph/manage_ptr.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/device/concat.hpp>
#include <utility>

namespace migraph {
namespace gpu {

wsttiger's avatar
wsttiger committed
11
shape hip_concat::compute_shape(std::vector<shape> inputs) const
12
13
14
15
16
17
{
    inputs.pop_back();
    return op.compute_shape(inputs);
}

std::vector<std::size_t> hip_concat::compute_offsets(const shape& output_shape,
wsttiger's avatar
wsttiger committed
18
                                                     const std::vector<argument> args) const
19
20
21
22
23
24
25
26
27
28
29
30
{
    std::vector<std::size_t> offsets;
    std::vector<std::size_t> offset(args[0].get_shape().lens().size(), 0);
    offset[op.axis] = 0;
    for(const auto& arg : args)
    {
        offsets.push_back(output_shape.index(offset));
        offset[op.axis] += arg.get_shape().lens()[op.axis];
    }
    return offsets;
}

wsttiger's avatar
wsttiger committed
31
32
argument
hip_concat::compute(context&, const shape& output_shape, const std::vector<argument>& args) const
33
34
35
36
37
38
39
40
{
    std::vector<std::size_t> offsets = compute_offsets(output_shape, args);
    return device::concat(output_shape, args, offsets);
}

} // namespace gpu

} // namespace migraph