Skip to main content

Module sync

Module sync 

Source
Expand description

This module provides conversions between Arc<Mutex<Array<T, D>>> and Arc<RwLock<Array<T, D>>> to DLPackTensor, allowing you to share data between Rust and DLPack while ensuring that the data is not modified by Rust while it’s used by DLPack and reciprocally. The locks will be held until the DLPackTensor is dropped, ensuring safe access to the data.

The following conversions to DLPack types are supported:

  • Arc<Mutex<Array<T, D>>> -> DLPackTensor
  • ReadOnly<Arc<RwLock<Array<T, D>>>> -> DLPackTensor, creating a read-only DLPack tensor and locking the RwLock for reading.
  • ReadWrite<Arc<RwLock<Array<T, D>>>> -> DLPackTensor, creating a read-write DLPack tensor and locking the RwLock for writing.