upfirdn2d.cpp 967 B

1234567891011121314151617181920212223
  1. #include <torch/extension.h>
  2. torch::Tensor upfirdn2d_op(const torch::Tensor& input, const torch::Tensor& kernel,
  3. int up_x, int up_y, int down_x, int down_y,
  4. int pad_x0, int pad_x1, int pad_y0, int pad_y1);
  5. #define CHECK_CUDA(x) TORCH_CHECK(x.type().is_cuda(), #x " must be a CUDA tensor")
  6. #define CHECK_CONTIGUOUS(x) TORCH_CHECK(x.is_contiguous(), #x " must be contiguous")
  7. #define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
  8. torch::Tensor upfirdn2d(const torch::Tensor& input, const torch::Tensor& kernel,
  9. int up_x, int up_y, int down_x, int down_y,
  10. int pad_x0, int pad_x1, int pad_y0, int pad_y1) {
  11. CHECK_CUDA(input);
  12. CHECK_CUDA(kernel);
  13. return upfirdn2d_op(input, kernel, up_x, up_y, down_x, down_y, pad_x0, pad_x1, pad_y0, pad_y1);
  14. }
  15. PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  16. m.def("upfirdn2d", &upfirdn2d, "upfirdn2d (CUDA)");
  17. }