<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShadersGraph",
  "identifier" : "/documentation/MetalPerformanceShadersGraph/MPSGraph/convolution2DWeightsGradient(_:source:outputShape:forwardConvolutionDescriptor:name:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders Graph",
      "MetalPerformanceShadersGraph"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSGraph(im)convolution2DWeightsGradientWithIncomingGradientTensor:sourceTensor:outputShape:forwardConvolutionDescriptor:name:"
  },
  "title" : "convolution2DWeightsGradient(_:source:outputShape:forwardConvolutionDescriptor:name:)"
}
-->

# convolution2DWeightsGradient(_:source:outputShape:forwardConvolutionDescriptor:name:)

Creates a 2D convolution gradient operation with respect to the weights tensor of the forward convolution.

```
func convolution2DWeightsGradient(_ incomingGradient: MPSGraphTensor, source: MPSGraphTensor, outputShape: [NSNumber], forwardConvolutionDescriptor: MPSGraphConvolution2DOpDescriptor, name: String?) -> MPSGraphTensor
```

## Parameters

`incomingGradient`

Incoming loss gradient tensor

`outputShape`

Shape of the forward pass source tensor

`forwardConvolutionDescriptor`

Forward convolution 2D op `descriptor`

`name`

The name for the operation.

## Return Value

A valid MPSGraphTensor object

## Discussion

If `W` is weights tensor to forward convolution, `R` is the result/returned tensor of forward convolution,
and `L` is the loss function, convolution2DWeightsGradientWithIncomingGradientTensor returns tensor `dL/dW = dL/dR * dR/dW`,
where `dL/dR` is the incomingGradient parameter.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)