---
title: synchronizeOptimizerData()
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/mlctensor/synchronizeoptimizerdata()
---

# synchronizeOptimizerData()

Synchronizes the optimizer data in host memory.

## Declaration

```swift
func synchronizeOptimizerData() -> Bool
```

## Return Value

Return Value true if synchronization is successful; otherwise, false.

## Discussion

Discussion This method synchronizes the optimizerData in host memory with latest contents in device memory. Only call this method once the graph, with which you used this tensor, finishes execution; otherwise the results in device memory may not be up to date. important: Don’t call this method from a completion callback when the device is a GPU.

## See Also

### Managing Tensor Data

- [synchronizeData()](mlcompute/mlctensor/synchronizedata().md)
- [copyDataFromDeviceMemory(toBytes:length:synchronizeWithDevice:)](mlcompute/mlctensor/copydatafromdevicememory(tobytes:length:synchronizewithdevice:).md)
- [bindAndWriteData(_:to:)](mlcompute/mlctensor/bindandwritedata(_:to:).md)
- [bindOptimizerData(_:deviceData:)](mlcompute/mlctensor/bindoptimizerdata(_:devicedata:).md)
