FilesLast commitLast update
3 days ago
9 months ago
1 month ago
7 months ago
4 days ago
2 months ago
1 month ago
4 days ago
1 month ago
10 days ago
README

Im2col

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×

Function Description

  • Operator function: image to columns. Sliding local window data is converted into column vectors and concatenated into a large tensor. Sliding windows are extracted from a batched input tensor. Consider a batched input tensor with shape (N, C, H, W) or (C, H, W), where N is the batch dimension, C is the channel dimension, and H, W indicate the image size. This operation flattens each sliding block of kernel_size within the spatial dimensions of the input into a column (that is, the last dimension) of a 3-D output tensor of (N, C ×∏\times \prod(kernel_size), L) or a 2-D output tensor of (C ×∏\times \prod(kernel_size), L), and L is the total number of such blocks.
  • Computation formula: L=∏d⌊spatial_size[d]+2×padding[d]−dilation[d]×(kernel_size[d]−1)−1stride[d]+1⌋L = \prod_{d} \lfloor \frac{spatial\_size[d] + 2 \times padding[d] - dilation[d] \times (kernel\_size[d] -1)-1}{stride[d]} + 1 \rfloor, where spatial_size is composed of H and W of the aforementioned input tensor.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
self Input tensor Input tensor with a 3-dimensional or 4-dimensional shape. INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, BFLOAT16, FLOAT16, FLOAT, DOUBLE, BOOL, COMPLEX32, COMPLEX64 ND
kernelSize Input array Kernel size. The size is 2. kernelSize[0] indicates the 'H' direction, and kernelSize[1] indicates the 'W' direction. INT64 -
dilation Input array Dilation parameter. The size is 2. dilation[0] indicates the 'H' direction, and dilation[1] indicates the 'W' direction. INT64 -
padding Input array Padding size. The size is 2. padding[0] indicates the H direction, and padding[1] indicates the W direction. INT64 -
stride Input array Stride. The size is 2. stride[0] indicates the H direction, and stride[1] indicates the W direction. INT64 -
out Output tensor Output tensor whose shape is derived from the parameters. INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64, UINT64, BFLOAT16, FLOAT16, FLOAT, DOUBLE, BOOL, COMPLEX32, COMPLEX64 ND
  • Atlas A3 products and Atlas A2 products: only FLOAT, FLOAT16, and BFLOAT16 are supported.

Constraint Description

  • The input tensor must be 3-dimensional or 4-dimensional.
  • The size of kernelSize, dilation, padding, and stride must be 2.
  • The values of kernelSize, dilation, and stride must be greater than 0.
  • The value of padding cannot be less than 0.

Invocation Description

Invocation Method Sample Code Description
aclnn invocation test_aclnn_im2col Invokes the Im2col operator through the aclnnIm2col API.
Graph-mode invocation test_geir_im2col Invokes the Im2col operator by building a graph through the operator IR.