Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

roi_pool.cpp 3.0 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
  1. #include "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> 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.roi_pool.roi_pool");
  14. static auto op = c10::Dispatcher::singleton()
  15. .findSchemaOrThrow("torchvision::roi_pool", "")
  16. .typed<decltype(roi_pool)>();
  17. return op.call(input, rois, spatial_scale, pooled_height, pooled_width);
  18. }
  19. std::tuple<at::Tensor, at::Tensor> roi_pool_symint(
  20. const at::Tensor& input,
  21. const at::Tensor& rois,
  22. double spatial_scale,
  23. c10::SymInt pooled_height,
  24. c10::SymInt pooled_width) {
  25. C10_LOG_API_USAGE_ONCE("torchvision.csrc.ops.roi_pool.roi_pool");
  26. static auto op = c10::Dispatcher::singleton()
  27. .findSchemaOrThrow("torchvision::roi_pool", "")
  28. .typed<decltype(roi_pool_symint)>();
  29. return op.call(input, rois, spatial_scale, pooled_height, pooled_width);
  30. }
  31. namespace detail {
  32. at::Tensor _roi_pool_backward(
  33. const at::Tensor& grad,
  34. const at::Tensor& rois,
  35. const at::Tensor& argmax,
  36. double spatial_scale,
  37. int64_t pooled_height,
  38. int64_t pooled_width,
  39. int64_t batch_size,
  40. int64_t channels,
  41. int64_t height,
  42. int64_t width) {
  43. static auto op = c10::Dispatcher::singleton()
  44. .findSchemaOrThrow("torchvision::_roi_pool_backward", "")
  45. .typed<decltype(_roi_pool_backward)>();
  46. return op.call(
  47. grad,
  48. rois,
  49. argmax,
  50. spatial_scale,
  51. pooled_height,
  52. pooled_width,
  53. batch_size,
  54. channels,
  55. height,
  56. width);
  57. }
  58. at::Tensor _roi_pool_backward_symint(
  59. const at::Tensor& grad,
  60. const at::Tensor& rois,
  61. const at::Tensor& argmax,
  62. double spatial_scale,
  63. c10::SymInt pooled_height,
  64. c10::SymInt pooled_width,
  65. c10::SymInt batch_size,
  66. c10::SymInt channels,
  67. c10::SymInt height,
  68. c10::SymInt width) {
  69. static auto op = c10::Dispatcher::singleton()
  70. .findSchemaOrThrow("torchvision::_roi_pool_backward", "")
  71. .typed<decltype(_roi_pool_backward_symint)>();
  72. return op.call(
  73. grad,
  74. rois,
  75. argmax,
  76. spatial_scale,
  77. pooled_height,
  78. pooled_width,
  79. batch_size,
  80. channels,
  81. height,
  82. width);
  83. }
  84. } // namespace detail
  85. TORCH_LIBRARY_FRAGMENT(torchvision, m) {
  86. m.def(TORCH_SELECTIVE_SCHEMA(
  87. "torchvision::roi_pool(Tensor input, Tensor rois, float spatial_scale, SymInt pooled_height, SymInt pooled_width) -> (Tensor, Tensor)"));
  88. m.def(TORCH_SELECTIVE_SCHEMA(
  89. "torchvision::_roi_pool_backward(Tensor grad, Tensor rois, Tensor argmax, float spatial_scale, SymInt pooled_height, SymInt pooled_width, SymInt batch_size, SymInt channels, SymInt height, SymInt width) -> Tensor"));
  90. }
  91. } // namespace ops
  92. } // namespace vision
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...