---
title: "sourceGradientTensors(for:)"
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/sourcegradienttensors(for:)"
---

# sourceGradientTensors(for:)

Gets the source gradient tensors for the layer in the training graph you specify.

## Declaration

```swift
func sourceGradientTensors(for layer: MLCLayer) -> [MLCTensor]
```

## Parameters

- `layer`: A layer in the training graph.

## Return Value

Return Value An array of tensors.

## See Also

### Inspecting Training Graphs

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