OpSharding

Struct OpSharding 

Source
pub struct OpSharding {
Show 13 fields pub type: i32, pub tile_shape: Option<ShapeProto>, pub tile_assignment_dimensions: Vec<i64>, pub tile_assignment_devices: Vec<i64>, pub tuple_shardings: Vec<OpSharding>, pub replicate_on_last_tile_dim: bool, pub metadata: Vec<OpMetadata>, pub last_tile_dims: Vec<i32>, pub iota_reshape_dims: Vec<i64>, pub iota_transpose_perm: Vec<i32>, pub is_shard_group: bool, pub shard_group_id: i64, pub shard_group_type: i32,
}
Expand description

LINT.IfChange

Fields§

§type: i32§tile_shape: Option<ShapeProto>

The shape of the sharded tile.

§tile_assignment_dimensions: Vec<i64>

The shape of the tile assignment tensor - this must be the same rank as tile_shape and the product of its dimensions must equal tile_assignment_devices.size().

§tile_assignment_devices: Vec<i64>

Flattened list of device IDs. The order of flattening is the same as used by IndexUtil::MultiToLinearIndex(tile_assignment_shape). Only one of tile_assignment_devices and iota_dimensions shall be non-empty.

§tuple_shardings: Vec<OpSharding>

If type == TUPLE, the sub-shardings, one per leaf node in the tuple shape, in pre-order. The tuple shape could be nested; here we store just a flattened list of all leaves in the tuple shape. Note that the tuple shape is not stored here; shardings do not store the shapes to which they are applied, this is inferred from the instruction this sharding gets attached to.

§replicate_on_last_tile_dim: bool

Only used for OTHER type. If true, data is sharded according to other dimensions of tile_assignment(), but replicated across devices along the last dimension. (Experimental)

§metadata: Vec<OpMetadata>

This field is used to track the source of this sharding, usually derived from instructions. Multple metadata may be populated if sharding is combined with other shardings. Metadata are to not be populated when type == TUPLE and instead metadata should be set on individual tuple elements.

§last_tile_dims: Vec<i32>

This field is used to represented the sharding type of each subgroup. For example, sharding={devices=[2,2,2,2]0,1,2,…,15 last_tile_dims={ replicate, manual, unreduced}} means that each of the last 3 dimensions in [2,2,2,2] represents a subgrouping in replicate, manual, unreduced sharding type respectively.

§iota_reshape_dims: Vec<i64>

Dimensions used to reshape the 1D iota array of device IDs. Only one of tile_assignment_devices and iota_reshape_dims shall be non-empty.

§iota_transpose_perm: Vec<i32>

Dimension permutations to transposed the iota array reshaped to iota_reshape_dims. This must have the same size as iota_reshape_dims.

§is_shard_group: bool

This field decides whether this op is in a shard group.

§shard_group_id: i64

This field is used to store the unique id of the shard group.

§shard_group_type: i32

Implementations§

Source§

impl OpSharding

Source

pub fn type(&self) -> Type

Returns the enum value of type, or the default if the field is set to an invalid enum value.

Source

pub fn set_type(&mut self, value: Type)

Sets type to the provided enum value.

Source

pub fn last_tile_dims( &self, ) -> FilterMap<Cloned<Iter<'_, i32>>, fn(i32) -> Option<Type>>

Returns an iterator which yields the valid enum values contained in last_tile_dims.

Source

pub fn push_last_tile_dims(&mut self, value: Type)

Appends the provided enum value to last_tile_dims.

Source

pub fn shard_group_type(&self) -> ShardGroupType

Returns the enum value of shard_group_type, or the default if the field is set to an invalid enum value.

Source

pub fn set_shard_group_type(&mut self, value: ShardGroupType)

Sets shard_group_type to the provided enum value.

Trait Implementations§

Source§

impl Clone for OpSharding

Source§

fn clone(&self) -> OpSharding

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpSharding

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OpSharding

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Message for OpSharding

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for OpSharding

Source§

fn eq(&self, other: &OpSharding) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for OpSharding

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.