---
title: "convolution2D(_:weights:descriptor:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/convolution2d(_:weights:descriptor:name:)"
---

# convolution2D(_:weights:descriptor:name:)

Creates a 2D (forward) convolution operation and returns the result tensor.

## Declaration

```swift
func convolution2D(_ source: MPSGraphTensor, weights: MPSGraphTensor, descriptor: MPSGraphConvolution2DOpDescriptor, name: String?) -> MPSGraphTensor
```

## Parameters

- `source`: Source tensor - must be a rank 4 tensor. The layout is defined by descriptor.dataLayout.
- `weights`: Weights tensor, must be rank 4. The layout is defined by descriptor.weightsLayout.
- `descriptor`: Specifies strides, dilation rates, paddings and layouts.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object
