CopyTensors property

Pointer<NativeFunction<OrtStatusPtr Function(Pointer<OrtEnv> env, Pointer<Pointer<OrtValue>> src_tensors, Pointer<Pointer<OrtValue>> dst_tensors, Pointer<OrtSyncStream> stream, Size num_tensors)>> CopyTensors
getter/setter pair

\brief Copy OrtValue instances containing Tensors between devices.

The overall copy must be between a single source device and a single destination device. i.e.

  • all src_tensors must have matching OrtMemoryInfo,
  • all dst_tensors must have matching OrtMemoryInfo.

OrtValue instances can be created by:

  • Use GetSharedAllocator to get the shared allocator for the OrtMemoryInfo if you need to allocate memory on the device.
  • Use CreateTensorAsOrtValue, CreateTensorWithDataAsOrtValue or CreateTensorWithDataAndDeleterAsOrtValue to create an OrtValue containing a tensor depending on whether you have existing data or not, and whether you want ORT to free the existing data once it is done with the OrtValue.

\paramin env The OrtEnv instance to use. The data transfer implementation is provided by an execution provider that is registered in this OrtEnv. \paramin src_tensors Array of OrtValue instances containing the source tensors to copy. \paramin dst_tensors Array of OrtValue instances to copy the source tensors to. \paramin stream Optional OrtSyncStream that can be used to perform the copy asynchronously. May be nullptr. \paramin num_tensors The number of tensors to copy. The size of src_tensors and dst_tensors must match.

\snippet{doc} snippets.dox OrtStatus Return Value

\since Version 1.23

Implementation

external ffi.Pointer<
  ffi.NativeFunction<
    OrtStatusPtr Function(
      ffi.Pointer<OrtEnv> env,
      ffi.Pointer<ffi.Pointer<OrtValue>> src_tensors,
      ffi.Pointer<ffi.Pointer<OrtValue>> dst_tensors,
      ffi.Pointer<OrtSyncStream> stream,
      ffi.Size num_tensors,
    )
  >
>
CopyTensors;