-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aten::_nested_tensor_softmax_with_shape (#1323)
Part of #1141. Depends on pytorch/pytorch#145467. - `_nested_tensor_softmax_with_shape`
- Loading branch information
1 parent
a6f4c32
commit b6786e3
Showing
3 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/ATen/native/nested/NestedTensorTransformerFunctions.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <ATen/ATen.h> | ||
#include <ATen/native/nested/NestedTensorTransformerFunctions.h> | ||
|
||
namespace at::native { | ||
|
||
Tensor NestedTensor_softmax_dropout_xpu( | ||
const Tensor& self, | ||
const Tensor& query) { | ||
std::optional<Tensor> attn_mask; | ||
|
||
attn_mask = NestedTensor_to_mask(query, 2, self.size(2)); | ||
attn_mask = attn_mask->to(query.device(), /*non-blocking=*/true); | ||
return _masked_softmax( | ||
self, | ||
*attn_mask, | ||
self.dim() - 1, | ||
/*mask type */ 1); // NestedTensor_to_mask produces a BxT mask | ||
} | ||
|
||
} // namespace at::native |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters