bindAndWriteData(_:forInputs:to:synchronous:)
Associates the given data with the input tensors, and if the device is a GPU, also copies the data to the device memory.
Declaration
func bindAndWriteData(_ inputsData: [String : MLCTensorData], forInputs inputTensors: [String : MLCTensor], to device: MLCDevice, synchronous: Bool) -> BoolParameters
- inputsData:
An array that contains the input data to write to device memory.
- inputTensors:
The list of tensors to perform writes on.
- device:
The compute device.
- synchronous:
A Boolean value that indicates whether to execute the copy to the device synchronously.
Return Value
true if the data is successfully associated with input tensors, otherwise false.
Discussion
Use this method if you execute the forward, gradient, and optimizer updates independently. Write the inputs to device memory before the layer executes the forward pass. Similarly, write the inputs—typically the initial gradient tensor—to device memory before the layer executes the gradient pass.
Use asynchronous execution for better performance, except when testing or debugging.