bughunter
(Matheus)
January 11, 2022, 12:41am
1
I can’t find anywhere the implementation of this code:
Tensor[K, C, output_size[0], output_size[1]]: The pooled RoIs.
"""
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(roi_align)
_assert_has_ops()
check_roi_boxes_shape(boxes)
rois = boxes
output_size = _pair(output_size)
if not isinstance(rois, torch.Tensor):
rois = convert_boxes_to_roi_format(rois)
return torch.ops.torchvision.roi_align(
input, rois, spatial_scale, output_size[0], output_size[1], sampling_ratio, aligned
)
class RoIAlign(nn.Module):
"""
See :func:`roi_align`.
"""
def __init__(
may be this is what you are looking
import torch
from torch import nn, Tensor
from torch.jit.annotations import BroadcastingList2
from torch.nn.modules.utils import _pair
from torchvision.extension import _assert_has_ops
from ..utils import _log_api_usage_once
from ._utils import convert_boxes_to_roi_format, check_roi_boxes_shape
def roi_align(
input: Tensor,
boxes: Union[Tensor, List[Tensor]],
output_size: BroadcastingList2[int],
spatial_scale: float = 1.0,
sampling_ratio: int = -1,
aligned: bool = False,
) -> Tensor:
"""
Performs Region of Interest (RoI) Align operator with average pooling, as described in Mask R-CNN.
bughunter
(Matheus)
January 11, 2022, 3:25pm
3
@talhaanwarch so the method is basically calling itself? Line 61 is calling line 13?
The CPU kernel can be found here the CUDA kernel here .
bughunter
(Matheus)
January 13, 2022, 2:13pm
5
Thank you @ptrblck ! That responds my question since I was interested in learning about how the ROI Align algorith was implemented since I was not able to understand just reading the Mask R CNN Paper.
If you don’t mind I’d like to ask another question now. Is there some documentation explaining how this cpp code is loaded into the python side? When I call torch.ops.torchvision.roi_align
, how does that load the cpp kernel that you sent above?
Thank you!
Are there plans to support Max mode in ROIALIGN @ptrblck
I’m not aware of any plans but also see that you’ve already created a feature request .