Skip to content

Commit 3dbe46c

Browse files
committed
Add fallback for USE_ONEMKL=OFF
1 parent 911524b commit 3dbe46c

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

src/ATen/native/xpu/SpectralOps.cpp

+18-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#else
44
#include <ATen/native/Resize.h>
55
#include <ATen/ops/_fft_c2c_native.h>
6+
#include <ATen/ops/_fft_c2r_native.h>
67
#endif // USE_ONEMKL
78

89
namespace at::native {
@@ -49,18 +50,33 @@ Tensor _fft_c2r_xpu(
4950
int64_t last_dim_size) {
5051
TORCH_CHECK(self.is_complex());
5152

53+
#if defined(USE_ONEMKL)
5254
return native::xpu::_fft_c2r_mkl(self, dim, normalization, last_dim_size);
55+
#else
56+
Tensor out_cpu = native::_fft_c2r_mkl(
57+
self.to(Device(at::kCPU)), dim, normalization, last_dim_size);
58+
return out_cpu.to(Device(at::kXPU));
59+
#endif // USE_ONEMKL
5360
}
5461

55-
Tensor _fft_c2r_xpu_out(
62+
Tensor& _fft_c2r_xpu_out(
5663
const Tensor& self,
5764
IntArrayRef dim,
5865
int64_t normalization,
5966
int64_t last_dim_size,
6067
Tensor& out) {
6168
TORCH_CHECK(self.is_complex());
6269

63-
return native::xpu::_fft_c2r_mkl_out(self, dim, normalization, last_dim_size, out);
70+
#if defined(USE_ONEMKL)
71+
return native::xpu::_fft_c2r_mkl_out(
72+
self, dim, normalization, last_dim_size, out);
73+
#else
74+
Tensor out_cpu = native::_fft_c2r_mkl(
75+
self.to(Device(at::kCPU)), dim, normalization, last_dim_size);
76+
at::native::resize_output(out, out_cpu.sizes());
77+
out.copy_(out_cpu);
78+
return out;
79+
#endif // USE_ONEMKL
6480
}
6581

6682
} // namespace at::native

0 commit comments

Comments
 (0)