Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/ATen/native/transformers/Attention.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include <ATen/native/nested/NestedTensorUtils.h>
#include <ATen/native/transformers/attention.h>
#include <ATen/native/transformers/sdp_utils_cpp.h>
#include <ATen/native/xpu/sycl/DropoutKernels.h>
#include <ATen/ops/_fill_mem_eff_dropout_mask_native.h>

#ifndef AT_PER_OPERATOR_HEADERS
#include <ATen/Functions.h>
Expand Down Expand Up @@ -294,5 +296,19 @@ std::tuple<Tensor, Tensor> native_multi_head_attention_xpu(
return std::make_tuple(std::move(proj), std::move(qkt));
}

/**
* get the mask for dropout. only used for testing, not much
* attention is paid to performance
*/
at::Tensor& _fill_mem_eff_dropout_mask_(
Tensor& self,
double dropout_p,
const int64_t seed,
const int64_t offset) {
auto mask = std::get<1>(xpu::dropout_kernel(self, dropout_p, true));
self.copy_(mask);
return self;
}

} // namespace native
} // namespace at
6 changes: 6 additions & 0 deletions yaml/native/native_functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7922,6 +7922,12 @@
SparseCsrXPU: angle_sparse_csr_out
tags: pointwise

- func: _fill_mem_eff_dropout_mask_(Tensor(a!) self, float dropout_p, int seed, int offset) -> Tensor(a!)
variants: function
dispatch:
XPU: _fill_mem_eff_dropout_mask_
tags: nondeterministic_seeded

- func: special_airy_ai(Tensor x) -> Tensor
python_module: special
structured_delegate: special_airy_ai.out
Expand Down