| Files | Last commit | Last update |
|---|---|---|
| 23 days ago | ||
| 23 days ago | ||
| 5 days ago | ||
| 5 days ago | ||
| 1 month ago | ||
| 5 days ago | ||
| 1 month ago | ||
| 23 days ago | ||
| 17 days ago |
Dilation2D
English | 简体中文
Applicable Products
| Product | Support |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 products | √ |
| Atlas A2 products | √ |
| Atlas 200I/500 A2 inference products | × |
| Atlas inference products | × |
| Atlas training products | × |
Function
-
Operator function: the 2D implementation of the morphological dilation operation. The operator performs the sliding window operation independently on each channel of the input image: at each window position, the maximum of the sum of the input value and the filter value is taken as the output.
-
Formula:
y[b,oh,ow,c]=maxfh,fw(x[b,oh×strideh+fh×rateh−pad_top,ow×stridew+fw×ratew−pad_left,c]+filter[fh,fw,c])y[b, oh, ow, c] = \max_{fh, fw} (x[b, oh \times stride_h + fh \times rate_h - pad\_top, ow \times stride_w + fw \times rate_w - pad\_left, c] + filter[fh, fw, c])
Here pad_toppad\_top and pad_leftpad\_left are determined by the padding mode: in SAME/CALCULATED mode they are computed by the formula below, and in VALID mode they are 0. Positions beyond the input boundaries are treated as negative infinity and do not participate in the max comparison.
Output Size Computation
Let the effective filter size be filter_h_eff=fH+(fH−1)×(rate_h−1)filter\_h\_eff = fH + (fH-1) \times (rate\_h-1), and filter_w_efffilter\_w\_eff is computed in the same way.
- SAME: oH=⌈H/stride_h⌉oH = \lceil H / stride\_h \rceil and oW=⌈W/stride_w⌉oW = \lceil W / stride\_w \rceil; the pad is computed as padh=max((oH−1)×stride_h+filter_h_eff−H,0)pad_h = \max((oH-1) \times stride\_h + filter\_h\_eff - H, 0) and then split evenly between top and bottom (pad_top=pad_h//2pad\_top = pad\_h // 2).
- VALID: oH=max(0,⌊(H−filter_h_eff+stride_h)/stride_h⌋)oH = \max(0, \lfloor (H - filter\_h\_eff + stride\_h) / stride\_h \rfloor), and oWoW is computed in the same way; there is no padding.
- CALCULATED: the pads attribute explicitly specifies [H_top,H_bottom,W_left,W_right][H\_top, H\_bottom, W\_left, W\_right]. Let hNum=H+H_top+H_bottom−filter_h_effhNum = H + H\_top + H\_bottom - filter\_h\_eff:
- ceil_mode=false (floor convention): oH=max(0,⌊hNum/stride_h⌋+1)oH = \max(0, \lfloor hNum / stride\_h \rfloor + 1); when hNum<0hNum < 0, the output is empty (oH=0oH = 0).
- ceil_mode=true (ceil convention): oH=max(0,⌈hNum/stride_h⌉+1)oH = \max(0, \lceil hNum / stride\_h \rceil + 1).
- oWoW is computed in the same way.
Parameters
| Parameter name | Input/Output/Attribute | Description | Data type | Data format |
|---|---|---|---|---|
| x | Input | 4D input tensor in NHWC or NCHW format. In NHWC, the filter shape is (fH,fW,C); in NCHW, it is (C,fH,fW). | FLOAT16 | ND |
| filter | Input | 3D filter tensor, whose C dimension is consistent with the C of x. In NHWC, the shape is (fH,fW,C); in NCHW, it is (C,fH,fW). | Same as x | ND |
| y | Output | 4D output tensor, with oH/oW derived from the input shape and attributes. | Same as x | ND |
| strides | Optional attribute | Four positive integers, the sliding window stride. In NHWC, the value is [sN, sH, sW, sC]; in NCHW, it is [sN, sC, sH, sW]. Value range: [1, 2147483647]. | ListInt | - |
| rates | Optional attribute | Four positive integers, the dilation rates. In NHWC, the value is [rN, rH, rW, rC]; in NCHW, it is [rN, rC, rH, rW]. Value range: [1, 2147483647]. | ListInt | - |
| padding_mode | Optional attribute | Padding mode: "SAME", "VALID", or "CALCULATED". The default value is "SAME". | String | - |
| pads | Optional attribute | Four non-negative integers, the explicit padding values [H_top, H_bottom, W_left, W_right]. The default value is {0,0,0,0}, which takes effect only in CALCULATED mode. Value range: [0, 2147483647]. | ListInt | - |
| ceil_mode | Optional attribute | Whether the output size computation uses ceil or floor. The default value is false. It takes effect only in CALCULATED mode. | Bool | - |
| data_format | Optional attribute | Data format: "NHWC" or "NCHW". The default value is "NHWC". | String | - |
Constraints
- The input x must be a 4D tensor, and the filter must be a 3D tensor.
- The dtypes of x and filter must be consistent; only FLOAT16 is supported.
- The channel count (C dimension) of the filter must be consistent with the channel count of x. In NHWC, the filter shape is (fH,fW,C); in NCHW, it is (C,fH,fW).
- The input dimensions and the values of strides/rates/pads must not exceed 2147483647 (the upper limit of int32); inputs that exceed this limit are rejected.
- strides and rates must be four positive integers. In NHWC, strides[0]=strides[3]=1 and rates[0]=rates[3]=1; in NCHW, strides[0]=strides[1]=1 and rates[0]=rates[1]=1.
- In CALCULATED mode, the pads must be smaller than the effective filter size, and the pads format is [H_top, H_bottom, W_left, W_right].
- Positions beyond the input boundaries are treated as negative infinity and do not participate in the max comparison.
- The three padding modes SAME, VALID, and CALCULATED are supported.
- Dynamic shapes are supported: when the input contains -1 (unknown dimension), the output is derived from the computable dimensions, and a dimension that cannot be computed outputs -1.
- Only Ascend 950 is supported.
Invocation Description
| Invocation method | Sample code | Description |
|---|---|---|
| GE graph mode | test_geir_dilation2_d | Calls the Dilation2D operator by building a graph through operator IR. |