#include "common/compiler_workarounds.hpp"
#include "gpu/amd/miopen_binary.hpp"
#include "gpu/amd/stream.hpp"
#include "gpu/amd/sycl_hip_scoped_context.hpp"
#include "xpu/sycl/buffer_memory_storage.hpp"
#include "xpu/sycl/memory_storage_helper.hpp"
namespace dnnl {
namespace impl {
namespace gpu {
namespace amd {
status_t miopen_binary_t::execute(const exec_ctx_t &ctx) const {
if (memory_desc_wrapper(pd()->src_md(0)).has_zero_dim())
return status::success;
amd::stream_t *hip_stream = utils::downcast<amd::stream_t *>(ctx.stream());
return hip_stream->interop_task([&](::sycl::handler &cgh) {
auto arg_src_0 = CTX_IN_SYCL_MEMORY(DNNL_ARG_SRC_0);
auto arg_src_1 = CTX_IN_SYCL_MEMORY(DNNL_ARG_SRC_1);
auto arg_dst = CTX_OUT_SYCL_MEMORY(DNNL_ARG_DST);
auto arg_scale0
= CTX_IN_SYCL_MEMORY(DNNL_ARG_ATTR_SCALES | DNNL_ARG_SRC_0);
auto arg_scale1
= CTX_IN_SYCL_MEMORY(DNNL_ARG_ATTR_SCALES | DNNL_ARG_SRC_1);
compat::host_task(
cgh, [= COMPAT_THIS_CAPTURE](const compat::interop_handle &ih) {
auto &sycl_engine
= *utils::downcast<amd::engine_t *>(hip_stream->engine());
auto sc = hip_sycl_scoped_context_handler_t(sycl_engine);
auto handle = hip_stream->get_miopen_handle();
void *a = arg_src_0.get_native_pointer(ih);
void *b = arg_src_1.get_native_pointer(ih);
void *c = arg_dst.get_native_pointer(ih);
void *s0 = arg_scale0.get_native_pointer(ih);
void *s1 = arg_scale1.get_native_pointer(ih);
pd()->binary_impl_->execute(handle, a, b, c, s0, s1);
});
});
}
} } } }