[object Object]

[object Object][object Object]undefined
[object Object]
  • Description: Performs pooling on the input feature map based on the region of interest (ROI). Each ROI is divided into pooled_h × pooled_w grids, and max pooling is performed on each grid. The pooling result and the one-dimensional index (argmax) of the maximum value in the channel are output.

  • Formulas:

    The shape of the input feature map xx is (N,C,H,W)(N, C, H, W), and the shape of the ROI tensor rois\text{rois} is (num_rois,5)(\text{num\_rois}, 5). Each row indicates (bn,x1,y1,x2,y2)(b_n, x_1, y_1, x_2, y_2). The scalar parameters are shs_h, sws_w (spatial_scale), pooled_h\text{pooled\_h}, and pooled_w\text{pooled\_w}. The subscript nn indicates the ROI index, cc indicates the channel, and (ph,pw)(\text{ph}, \text{pw}) indicates the pooling grid.

    • ROI mapping to the feature map: The ROI coordinates are multiplied by spatial_scale to obtain the floating-point interval on the feature map.

      x~1=x1sw,y~1=y1sh,x~2=(x2+1)sw,y~2=(y2+1)sh\tilde{x}_1 = x_1 s_w,\quad \tilde{y}_1 = y_1 s_h,\quad \tilde{x}_2 = (x_2+1)s_w,\quad \tilde{y}_2 = (y_2+1)s_h Wroi=x~2x~1,Hroi=y~2y~1W_{\text{roi}} = \tilde{x}_2 - \tilde{x}_1,\qquad H_{\text{roi}} = \tilde{y}_2 - \tilde{y}_1

      If Wroi0W_{\text{roi}} \le 0 or Hroi0H_{\text{roi}} \le 0, the value of yy for the ROI is all 0s, and the value of argmax\text{argmax} is all -1.

    • Bin step and range: Each pooling grid (ph, pw) corresponds to a bin in the ROI. The step and floating-point range are as follows:

      Δw=Wroipooled_w,Δh=Hroipooled_h\Delta w = \frac{W_{\text{roi}}}{\text{pooled\_w}},\qquad \Delta h = \frac{H_{\text{roi}}}{\text{pooled\_h}} w~1=pwΔw+x~1,w~2=(pw+1)Δw+x~1\tilde{w}_1 = \text{pw} \cdot \Delta w + \tilde{x}_1,\quad \tilde{w}_2 = (\text{pw}+1) \cdot \Delta w + \tilde{x}_1 h~1=phΔh+y~1,h~2=(ph+1)Δh+y~1\tilde{h}_1 = \text{ph} \cdot \Delta h + \tilde{y}_1,\quad \tilde{h}_2 = (\text{ph}+1) \cdot \Delta h + \tilde{y}_1

      The value is rounded and cropped to [0,W)×[0,H)[0, W) \times [0, H).

      w1=clip(w~1,0,W),w2=clip(w~2,0,W)w_1 = \text{clip}(\lfloor\tilde{w}_1\rfloor,\, 0,\, W),\quad w_2 = \text{clip}(\lceil\tilde{w}_2\rceil,\, 0,\, W) h1=clip(h~1,0,H),h2=clip(h~2,0,H)h_1 = \text{clip}(\lfloor\tilde{h}_1\rfloor,\, 0,\, H),\quad h_2 = \text{clip}(\lceil\tilde{h}_2\rceil,\, 0,\, H)

      where clip(a,l,u)=min(max(a,l),u)\text{clip}(a, l, u) = \min(\max(a, l), u). If w2w1w_2 \le w_1 or h2h1h_2 \le h_1, the bin is empty, that is, y=0y = 0 and argmax=1\text{argmax} = -1.

    • Pooling output and Argmax: Record b=rois[n,0]b = \text{rois}[n,0] and R={(h,w):h1h<h2,w1w<w2}R = \{(h,w): h_1 \le h < h_2,\, w_1 \le w < w_2\} in the bin area.

      y[n,c,ph,pw]=max(h,w)Rx[b,c,h,w]y[n,c,\text{ph},\text{pw}] = \max_{(h,w) \in R} x[b,c,h,w]

      (If RR is empty, the value is 0.)

      argmax[n,c,ph,pw]=hW+w\text{argmax}[n,c,\text{ph},\text{pw}] = h^* W + w^*

      (h,w)(h^*, w^*)is the position of the maximum value in the bin (the first value is obtained). If RR is empty, the value is -1.

    • Output shape:

      [object Object]undefined
[object Object]

Each operator has calls. First, [object Object] is called to obtain the workspace size required for computation and the executor that contains the operator computation process. Then, [object Object] is called to perform computation.

[object Object]
[object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns:

    [object Object]: status code. For details, see .

    The first-phase API implements input parameter validation. The following error codes may be returned.

    [object Object]
[object Object]
  • Parameters

    [object Object]
  • Returns:

    [object Object]: status code. For details, see .

[object Object]
  • Deterministic computation:
    • [object Object] defaults to a deterministic implementation.
[object Object]

The following example is for reference only. For details, see . During actual call, use opgen to generate aclnnop/aclnn_roi_pooling_with_arg_max.h. If the generated header file or API signature is different, use the generated API.

[object Object]