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

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