|
| 1 | +#include <ATen/core/Tensor.h> |
| 2 | +#include <ATen/core/op_registration/adaption.h> |
| 3 | +#include <ATen/native/cpu/mixed_data_type.h> |
| 4 | +#include <ATen/native/xpu/sycl/FractionalMaxPool3dKernels.h> |
| 5 | +#include <ATen/ops/empty.h> |
| 6 | + |
| 7 | +#include <xpu/ATen/ops/fractional_max_pool3d_backward_native.h> |
| 8 | +#include <xpu/ATen/ops/fractional_max_pool3d_native.h> |
| 9 | + |
| 10 | +namespace at::native { |
| 11 | + |
| 12 | +TORCH_IMPL_FUNC(fractional_max_pool3d_out_xpu) |
| 13 | +(const Tensor& input, |
| 14 | + int64_t poolSizeT, |
| 15 | + int64_t poolSizeH, |
| 16 | + int64_t poolSizeW, |
| 17 | + int64_t outputT, |
| 18 | + int64_t outputH, |
| 19 | + int64_t outputW, |
| 20 | + const Tensor& randomSamples, |
| 21 | + int64_t numBatch, |
| 22 | + int64_t numPlanes, |
| 23 | + int64_t inputT, |
| 24 | + int64_t inputH, |
| 25 | + int64_t inputW, |
| 26 | + const Tensor& output, |
| 27 | + const Tensor& indices) { |
| 28 | + xpu::fractional_max_pool3d_kernel( |
| 29 | + input, |
| 30 | + poolSizeT, |
| 31 | + poolSizeH, |
| 32 | + poolSizeW, |
| 33 | + outputT, |
| 34 | + outputH, |
| 35 | + outputW, |
| 36 | + randomSamples, |
| 37 | + numBatch, |
| 38 | + numPlanes, |
| 39 | + inputT, |
| 40 | + inputH, |
| 41 | + inputW, |
| 42 | + output, |
| 43 | + indices); |
| 44 | +} |
| 45 | + |
| 46 | +Tensor& fractional_max_pool3d_backward_out_xpu( |
| 47 | + const Tensor& grad_output, |
| 48 | + const Tensor& input, |
| 49 | + IntArrayRef pool_size, |
| 50 | + IntArrayRef output_size, |
| 51 | + const Tensor& indices, |
| 52 | + Tensor& grad_input) { |
| 53 | + globalContext().alertNotDeterministic( |
| 54 | + "fractional_max_pool3d_backward_out_xpu"); |
| 55 | + xpu::fractional_max_pool3d_backward_kernel( |
| 56 | + grad_input, grad_output, input, output_size, indices); |
| 57 | + return grad_input; |
| 58 | +} |
| 59 | + |
| 60 | +Tensor fractional_max_pool3d_backward_xpu( |
| 61 | + const Tensor& grad_output, |
| 62 | + const Tensor& input, |
| 63 | + IntArrayRef pool_size, |
| 64 | + IntArrayRef output_size, |
| 65 | + const Tensor& indices) { |
| 66 | + globalContext().alertNotDeterministic("fractional_max_pool3d_backward_xpu"); |
| 67 | + Tensor grad_input = at::empty({0}, input.options()); |
| 68 | + xpu::fractional_max_pool3d_backward_kernel( |
| 69 | + grad_input, grad_output, input, output_size, indices); |
| 70 | + return grad_input; |
| 71 | +} |
| 72 | + |
| 73 | +} // namespace at::native |
0 commit comments