ttnn.conv_transpose2d

ttnn.conv_transpose2d = Operation(python_fully_qualified_name='ttnn.conv_transpose2d', function=<ttnn._ttnn.operations.conv.conv_transpose2d_t object>, preprocess_golden_function_inputs=<function default_preprocess_golden_function_inputs>, golden_function=None, postprocess_golden_function_outputs=<function default_postprocess_golden_function_outputs>, is_cpp_operation=True, is_experimental=False)

Applies a 2D transposed convolution operator over an input image composed of several input planes.

This module can be seen as the gradient of Conv2d with respect to its input. It is also known as a fractionally-strided convolution or a deconvolution

The input tensor is expected in the following format (N x H x W x C) differs from PyTorch where:

  • N is the batch size

  • H is the height of the input

  • W is the width of the input

  • C is the number of channels in the input

The weight tensor is expected in the following format (C x O / G x K_H x K_W). The bias tensor is optional and expected in the following format (O / G ). Where:

  • C is the number of input channels

  • O is the number of output channels

  • G is the number of groups

  • K_H is the height of the kernel

  • K_W is the width of the kernel

The shape of the output tensor is given by the following equation :

  • H_out = (H_in - 1) * stride[0] - 2 * padding[0] + dilation[0] * (kernel_size[0] - 1) + output_padding[0] + 1

  • W_out = (W_in - 1) * stride[1] - 2 * padding[1] + dilation[1] * (kernel_size[1] - 1) + output_padding[1] + 1

Parameters:
  • input_tensor (ttnn.Tensor) – the input tensor.

  • weight_tensor (ttnn.Tensor) – the weight tensor.

  • bias_tensor (ttnn.Tensor, None) – optional bias tensor. Default: None

  • device (ttnn.IDevice) – the device to use.

  • in_channels (int) – number of input channels.

  • out_channels (int) – number of output channels.

  • batch_size (int) – batch size.

  • input_height (int) – height of the input tensor.

  • input_width (int) – width of the input tensor.

  • kernel_size (tuple[int , int]) – size of the convolving kernel.

  • stride (tuple[int, int]) – stride of the cross-correlation.

  • padding (tuple[int, int] or tuple[int, int, int, int])) – zero-padding added to both sides of the input. [pad_height, pad_width] or [pad_top, pad_bottom, pad_left, pad_right].

  • dilation (tuple[int, int]) – spacing between kernel elements.

  • groups (int) – number of blocked connections from input channels to output channels.

  • conv_config (ttnn.Conv2dConfig, None) – configuration for convolution. Default: None

  • compute_config (ttnn.DeviceComputeKernelConfig, None) – configuration for compute kernel. Default: None

  • mirror_kernel (bool) – Determines if the op should mirror the kernel internally. Should be set to True if the kernel has already been mirrored.

  • queue_id (int) – the queue id to use for the operation. Default: 0.

  • return_output_dim (bool) – If true, the op also returns the height and width of the output tensor in [N, H, W, C] format,

  • return_weights_and_bias (bool) – If true, the op also returns the preprocessed weight and bias on device .

Returns:

The output tensor, output height and width, and the preprocessed weights and bias.

Return type:

[ttnn.Tensor]: the output tensor, when return_output_dim = False and return_weights_and_bias = False

Return type:

[ttnn.Tensor, Tuple[int, int]]: the output tensor, and it’s height and width, if return_output_dim = True

Return type:

[ttnn.Tensor, Tuple[ttnn.Tensor, ttnn.Tensor]]: the output tensor, and it’s height and width, if return_weights_and_bias = True

Return type:

[ttnn.Tensor, Tuple[int, int], Tuple[ttnn.Tensor, ttnn.Tensor]]: the output tensor, and it’s height and width, if return_output_dim = True and return_weights_and_bias = True