8000 Add XPU device to nested_layer_norm (#148593) · pytorch/pytorch@215f856 · GitHub
[go: up one dir, main page]

Skip to content

Commit 215f856

Browse files
min-jean-chopytorchmergebot
authored andcommitted
Add XPU device to nested_layer_norm (#148593)
Work with intel/torch-xpu-ops#1416 . Pull Request resolved: #148593 Approved by: https://github.com/guangyey, https://github.com/jbschlosser
1 parent 66300d3 commit 215f856

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

aten/src/ATen/native/nested/NestedTensorMath.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ std::tuple<Tensor, Tensor, Tensor> nested_layer_norm(
172172
std::nullopt /* pin_memory */,
173173
at::MemoryFormat::Contiguous);
174174
auto options = input_buffer.options();
175-
if (input_buffer.is_cuda()) {
176-
auto acc_type = at::toAccumulateType(input_buffer.scalar_type(), true);
175+
if (input_buffer.is_cuda() || input_buffer.is_xpu()) {
176+
auto acc_type = at::toAccumulateType(input_buffer.scalar_type(), input_buffer.device().type());
177177
options = options.dtype(acc_type);
178178
}
179179
Tensor mean = at::empty({M}, options);
180180
Tensor rstd = at::empty({M}, options);
181181
LayerNormKernel(
182-
input_buffer.is_cuda() ? kCUDA : kCPU,
182+
input_buffer.device().type(),
183183
input_buffer,
184184
*weight_contig,
185185
*bias_contig,

0 commit comments

Comments
 (0)
0