Struct candle_nn::var_builder::ShardedSafeTensors
source · pub struct ShardedSafeTensors(/* private fields */);
Implementations§
source§impl ShardedSafeTensors
impl ShardedSafeTensors
sourcepub unsafe fn var_builder<P: AsRef<Path>>(
paths: &[P],
dtype: DType,
dev: &Device
) -> Result<ShardedVarBuilder<'static>>
pub unsafe fn var_builder<P: AsRef<Path>>( paths: &[P], dtype: DType, dev: &Device ) -> Result<ShardedVarBuilder<'static>>
Initializes a VarBuilder
that retrieves tensors stored in a collection of safetensors
files and make them usable in a sharded way.
§Safety
The unsafe is inherited from [memmap2::MmapOptions
].
Trait Implementations§
source§impl Backend for ShardedSafeTensors
impl Backend for ShardedSafeTensors
Get part of a tensor, typically used to do Tensor Parallelism sharding.
If the tensor is of size (1024, 1024).
dim
corresponds to the dimension to slice into
rank
is the rank of the current process
world_size
is the total number of ranks in the process group
get_sharded("tensor", 0, 0, 2)
means tensor.i((..512))
get_sharded("tensor", 0, 1, 2)
means tensor.i((512..))
get_sharded("tensor", 1, 0, 2)
means tensor.i((.., ..512))
Auto Trait Implementations§
impl Freeze for ShardedSafeTensors
impl RefUnwindSafe for ShardedSafeTensors
impl Send for ShardedSafeTensors
impl Sync for ShardedSafeTensors
impl Unpin for ShardedSafeTensors
impl UnwindSafe for ShardedSafeTensors
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more