pub struct ShardingSpec {
pub node_id: usize,
pub shard_dim: usize,
pub num_shards: usize,
pub shard_to_device: Vec<Device>,
}Expand description
Tensor sharding specification for model parallelism.
Fields§
§node_id: usizeNode ID that this sharding applies to
shard_dim: usizeDimension along which to shard
num_shards: usizeNumber of shards
shard_to_device: Vec<Device>Device assignment for each shard
Implementations§
Source§impl ShardingSpec
impl ShardingSpec
Sourcepub fn new(node_id: usize, shard_dim: usize, devices: Vec<Device>) -> Self
pub fn new(node_id: usize, shard_dim: usize, devices: Vec<Device>) -> Self
Create a new sharding specification.
Sourcepub fn device_for_shard(&self, shard_id: usize) -> Option<&Device>
pub fn device_for_shard(&self, shard_id: usize) -> Option<&Device>
Get the device for a specific shard.
Sourcepub fn is_valid_shard(&self, shard_id: usize) -> bool
pub fn is_valid_shard(&self, shard_id: usize) -> bool
Check if a shard ID is valid.
Trait Implementations§
Source§impl Clone for ShardingSpec
impl Clone for ShardingSpec
Source§fn clone(&self) -> ShardingSpec
fn clone(&self) -> ShardingSpec
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ShardingSpec
impl Debug for ShardingSpec
Source§impl PartialEq for ShardingSpec
impl PartialEq for ShardingSpec
impl Eq for ShardingSpec
impl StructuralPartialEq for ShardingSpec
Auto Trait Implementations§
impl Freeze for ShardingSpec
impl RefUnwindSafe for ShardingSpec
impl Send for ShardingSpec
impl Sync for ShardingSpec
impl Unpin for ShardingSpec
impl UnwindSafe for ShardingSpec
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