---
title: "padTensor(_:with:leftPadding:rightPadding:constantValue:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/padtensor(_:with:leftpadding:rightpadding:constantvalue:name:)"
---

# padTensor(_:with:leftPadding:rightPadding:constantValue:name:)

Creates a padding operation and returns the result tensor.

## Declaration

```swift
func padTensor(_ tensor: MPSGraphTensor, with paddingMode: MPSGraphPaddingMode, leftPadding: [NSNumber], rightPadding: [NSNumber], constantValue: Double, name: String?) -> MPSGraphTensor
```

## Parameters

- `tensor`: The input tensor.
- `paddingMode`: The parameter that defines the padding mode.
- `leftPadding`: The parameter that defines how much padding the operation applies to the input tensor before each dimension - must be of size rank(tensor).
- `rightPadding`: The parameter that defines how much padding the operation applies to the input tensor after each dimension - must be of size rank(tensor).
- `constantValue`: The constant value the operation uses when paddingMode = MPSGraphPaddingModeConstant.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object.
