ps_roi_pool.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "ps_roi_pool.h"
  2. #include <ATen/core/dispatch/Dispatcher.h>
  3. #include <torch/library.h>
  4. #include <torch/types.h>
  5. namespace vision {
  6. namespace ops {
  7. std::tuple<at::Tensor, at::Tensor> ps_roi_pool(
  8. const at::Tensor& input,
  9. const at::Tensor& rois,
  10. double spatial_scale,
  11. int64_t pooled_height,
  12. int64_t pooled_width) {
  13. C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.ps_roi_pool.ps_roi_pool");
  14. static auto op = c10::Dispatcher::singleton()
  15. .findSchemaOrThrow("torchvision::ps_roi_pool", "")
  16. .typed<decltype(ps_roi_pool)>();
  17. return op.call(input, rois, spatial_scale, pooled_height, pooled_width);
  18. }
  19. namespace detail {
  20. at::Tensor _ps_roi_pool_backward(
  21. const at::Tensor& grad,
  22. const at::Tensor& rois,
  23. const at::Tensor& channel_mapping,
  24. double spatial_scale,
  25. int64_t pooled_height,
  26. int64_t pooled_width,
  27. int64_t batch_size,
  28. int64_t channels,
  29. int64_t height,
  30. int64_t width) {
  31. static auto op =
  32. c10::Dispatcher::singleton()
  33. .findSchemaOrThrow("torchvision::_ps_roi_pool_backward", "")
  34. .typed<decltype(_ps_roi_pool_backward)>();
  35. return op.call(
  36. grad,
  37. rois,
  38. channel_mapping,
  39. spatial_scale,
  40. pooled_height,
  41. pooled_width,
  42. batch_size,
  43. channels,
  44. height,
  45. width);
  46. }
  47. } // namespace detail
  48. TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  49. m.def(TORCH_SELECTIVE_SCHEMA(
  50. "torchvision::ps_roi_pool(Tensor input, Tensor rois, float spatial_scale, int pooled_height, int pooled_width) -> (Tensor, Tensor)"));
  51. m.def(TORCH_SELECTIVE_SCHEMA(
  52. "torchvision::_ps_roi_pool_backward(Tensor grad, Tensor rois, Tensor channel_mapping, float spatial_scale, int pooled_height, int pooled_width, int batch_size, int channels, int height, int width) -> Tensor"));
  53. }
  54. } // namespace ops
  55. } // namespace vision