Contents

bindAndWriteData(_:forInputs:to:batchSize: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, batchSize: Int, synchronous: Bool) -> Bool

Parameters

  • 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.

  • batchSize:

    The batch size.

  • 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.

See Also

Associating Data with Input Tensors