convert.cpp 753 Bytes
Newer Older
1
#include <migraphx/gpu/device/convert.hpp>
2
3
4
5
6
7
8
#include <migraphx/gpu/device/nary.hpp>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
namespace gpu {
namespace device {

Shucai Xiao's avatar
Shucai Xiao committed
9
10
void convert(
    hipStream_t stream, const argument& result, const argument& arg, float scale, float shift)
11
{
12
13
    result.visit([&](auto output) {
        arg.visit([&](auto input) {
14
15
            const auto* input_ptr = device_cast(input.data());
            auto* output_ptr      = device_cast(output.data());
Shucai Xiao's avatar
Shucai Xiao committed
16
17
            gs_launch(stream, result.get_shape().elements())(
                [=](auto i) { output_ptr[i] = input_ptr[i] * scale + shift; });
18
19
20
21
22
23
24
25
        });
    });
}

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