<!--
{
  "availability" : [
    "iOS: 10.0.0 - 11.0.0",
    "iPadOS: 10.0.0 - 11.0.0",
    "macOS: 10.13.0 -",
    "tvOS: 10.0.0 - 11.0.0",
    "visionOS: 1.0.0 - 1.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSCNNConvolution/init(device:convolutionDescriptor:kernelWeights:biasTerms:flags:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSCNNConvolution(im)initWithDevice:convolutionDescriptor:kernelWeights:biasTerms:flags:"
  },
  "title" : "init(device:convolutionDescriptor:kernelWeights:biasTerms:flags:)"
}
-->

# init(device:convolutionDescriptor:kernelWeights:biasTerms:flags:)

Initializes a convolution kernel.

```
init(device: any MTLDevice, convolutionDescriptor: MPSCNNConvolutionDescriptor, kernelWeights: UnsafePointer<Float>, biasTerms: UnsafePointer<Float>?, flags: MPSCNNConvolutionFlags)
```

## Parameters

`device`

The device on which this kernel will run.

`convolutionDescriptor`

A pointer to a valid convolution descriptor.

`kernelWeights`

A pointer to a weights array.

    Each entry is a float value. The number of entries is equal to [`inputFeatureChannels`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionDescriptor/inputFeatureChannels)         `*`     [`outputFeatureChannels`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionDescriptor/outputFeatureChannels)         `*`     [`kernelHeight`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionDescriptor/kernelHeight)         `*`     [`kernelWidth`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionDescriptor/kernelWidth)    .

    The layout of the filter weight is arranged so that it can be reinterpreted as a 4D tensor (array)     `weight[outputChannels][kernelHeight][kernelWidth][inputChannels/groups]`

    Weights are converted to half float precision (    `fp16`    ) internally for best performance.

`biasTerms`

A pointer to bias terms to be applied to the convolution output.

    Each entry is a float value. The number of entries is the number of output feature maps.

`flags`

Currently unused.

    This value must be [`MPSCNNConvolutionFlags.none`](/documentation/MetalPerformanceShaders/MPSCNNConvolutionFlags/none)    .

## Return Value

A valid [`MPSCNNConvolution`](/documentation/MetalPerformanceShaders/MPSCNNConvolution) object or `nil`, if failure.

---

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)