---
title: "gradientTensor(forInput:)"
framework: ML Compute
role: symbol
role_heading: Instance Method
platforms: [iOS 14.0+, iPadOS 14.0+, Mac Catalyst 14.0+, macOS 11.0+, tvOS 14.0+]
path: "mlcompute/mlctraininggraph/gradienttensor(forinput:)"
---

# gradientTensor(forInput:)

Gets the gradient tensor for the input tensor you specify.

## Declaration

```swift
func gradientTensor(forInput input: MLCTensor) -> MLCTensor?
```

## Parameters

- `input`: An input tensor.

## Return Value

Return Value A gradient tensor.

## See Also

### Inspecting Training Graphs

- [bindOptimizerData(_:deviceData:with:)](mlcompute/mlctraininggraph/bindoptimizerdata(_:devicedata:with:).md)
- [optimizer](mlcompute/mlctraininggraph/optimizer.md)
- [deviceMemorySize](mlcompute/mlctraininggraph/devicememorysize.md)
- [sourceGradientTensors(for:)](mlcompute/mlctraininggraph/sourcegradienttensors(for:).md)
- [resultGradientTensors(for:)](mlcompute/mlctraininggraph/resultgradienttensors(for:).md)
- [gradientData(forParameter:layer:)](mlcompute/mlctraininggraph/gradientdata(forparameter:layer:).md)
