conv3d_backprop_filter

Description

Computes 3D deconvolution of the float32 type with the given 6HD data and 6HD out_backprop.

The data tensor has a 6HD shape of (N, D, C1, H, W, C0). The out_backprop tensor has a 6HD shape of (N, D, C1, H, W, C0).

Prototype

conv3d_backprop_filter(x, out_backprop, filter_size, para_dict)

Parameters

  • x: a 6HD Tensor of type float16, for the feature map of 3D convolution.
  • out_backprop: backprop of the 3D convolution. Currently, the float16 type is supported.
  • filter_size: a weight for 3D convolution.
  • para_dict: a dictionary for the key-value pairs, including the following keys:
    • strides: a list of the strides along the D, H, and W directions of the feature map.
    • pads: a list of the padding lines along the D, H, and W directions of the feature map.
    • dilations: a list of the dilations along the D, H, and W directions of the filter.
    • res_dtype: output data type.
    • kernel_name: operator name.
    • group_dict: a dictionary of 3dw group convolution arguments with respect to the filter, including:

      1. fmap_c, C dimension size of the feature map.

      2. cout, batch size of out_backprop.

      3. groups, argument for group convolution.

      4. cout0, which is tbe_platform.C0_SIZE. Defaults to 16.

      5. cin0, which is tbe_platform.C0_SIZE. Defaults to 16.

      The computation formula is as follows.

      lcm(param1, param2): calculates the least common multiple.

      mag_factor0 = lcm(fmap_c // groups, cin0) // (fmap_c // groups)

      mag_factor1 = lcm(cout // groups, cout0) // (cout // groups)

      mag_factor = min(lcm(mag_factor0, mag_factor1), groups)

      cin1_g = (mag_factor * fmap_c // groups + cin0 - 1) // cin0

      cout_g = (mag_factor * cout // groups + cout0 - 1) // cout0 * cout0

      group_dict = {"real_g": (groups + mag_factor - 1) // mag_factor,

      "mag_factor": mag_factor,

      "cin1_g": cin1_g,

      "cout_g": cout_g,

      "cin_ori": fmap_c,

      "cout_ori": cout}

Returns

res_tensor: result tensor.

Restrictions

This API cannot be used in conjunction with other TBE DSL APIs.

Applicability

Atlas 200/300/500 Inference Product

Atlas Training Series Product

Example

from tbe import tvm
from tbe import dsl

shape_dedy = (16, 4, 1, 36, 36, 16)
out_backprop_dtype = "float16"
filter_sizes = [16, 2, 16, 3, 3]
shape_fmap = (16, 8, 1, 72, 72, 16)
x_dtype = "float16"

dedy = tvm.placeholder(shape_dedy, name="dedy", dtype=out_backprop_dtype)
fmap = tvm.placeholder(shape_fmap, name="fmap", dtype=x_dtype)

strides = [2, 2, 2]
pads = [0, 0, 0, 1, 0, 1]
dilations = [1, 1, 1, 1, 1]
res_dtype = "float32"
kernel_name = "conv3d_backprop_filter_dx_16_8_72_72_16_dy_16_4_36_36_16_dw_2_3_3_16_16_s_1_2_2_2_1_p_SAME"
group_dict = {'real_g': 1, 'mag_factor': 1, 'cin1_g': 1, 'cout_g': 16, 'cin_ori': 16, 'cout_ori': 16}

para_dict = {
    "strides": strides,
    "pads": pads,
    "dilations": dilations,
    "res_dtype": res_dtype,
    "kernel_name": kernel_name,
    "group_dict": group_dict
}

dedw = dsl.conv3d_backprop_filter(
    x=fmap,
    out_backprop=dedy,
    filter_size=filter_sizes,
    para_dict=para_dict
)