-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add aten::_thnn_fused_gru_cell and _thnn_fused_lstm_cell (#926)
- [x] thnn_fused_gru_cell_forward - [x] thnn_fused_gru_cell_backward - [x] thnn_fused_lstm_cell_forward - [x] thnn_fused_lstm_cell_backward --------- Co-authored-by: Yutao Xu <[email protected]>
- Loading branch information
1 parent
214f33b
commit 23575f5
Showing
7 changed files
with
1,081 additions
and
30 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <ATen/ATen.h> | ||
#include <ATen/native/xpu/sycl/RNNKernels.h> | ||
|
||
namespace at::native { | ||
|
||
std::tuple<Tensor, Tensor, Tensor> _thnn_fused_lstm_cell_xpu( | ||
const Tensor& input_gates, | ||
const Tensor& hidden_gates, | ||
const Tensor& cx, | ||
const std::optional<Tensor>& input_bias_opt, | ||
const std::optional<Tensor>& hidden_bias_opt) { | ||
return native::xpu::_thnn_fused_lstm_cell_kernel( | ||
input_gates, hidden_gates, cx, input_bias_opt, hidden_bias_opt); | ||
} | ||
|
||
std::tuple<Tensor, Tensor, Tensor> _thnn_fused_lstm_cell_backward_xpu( | ||
const std::optional<Tensor>& grad_hy_opt, | ||
const std::optional<Tensor>& grad_cy_opt, | ||
const Tensor& cx, | ||
const Tensor& cy, | ||
const Tensor& workspace, | ||
bool has_bias) { | ||
return native::xpu::_thnn_fused_lstm_cell_backward_kernel( | ||
grad_hy_opt, grad_cy_opt, cx, cy, workspace, has_bias); | ||
} | ||
|
||
std::tuple<at::Tensor, at::Tensor> _thnn_fused_gru_cell_xpu( | ||
const Tensor& input_gates, | ||
const Tensor& hidden_gates, | ||
const Tensor& hx, | ||
const std::optional<at::Tensor>& input_bias, | ||
const std::optional<at::Tensor>& hidden_bias) { | ||
return native::xpu::_thnn_fused_gru_cell_kernel( | ||
input_gates, hidden_gates, hx, input_bias, hidden_bias); | ||
} | ||
|
||
std::tuple<Tensor, Tensor, Tensor, Tensor, Tensor> | ||
_thnn_fused_gru_cell_backward_xpu( | ||
const Tensor& grad_hy, | ||
const Tensor& workspace, | ||
bool has_bias) { | ||
return native::xpu::_thnn_fused_gru_cell_backward_kernel( | ||
grad_hy, workspace, has_bias); | ||
} | ||
|
||
} // 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
Oops, something went wrong.