LayoutProto

Struct LayoutProto 

Source
pub struct LayoutProto {
Show 13 fields pub dim_level_types: Vec<i32>, pub dim_unique: Vec<bool>, pub dim_ordered: Vec<bool>, pub minor_to_major: Vec<i64>, pub tiles: Vec<TileProto>, pub tail_padding_alignment_in_elements: i64, pub element_size_in_bits: i64, pub memory_space: i64, pub index_primitive_type: i32, pub pointer_primitive_type: i32, pub physical_shape: Option<Box<ShapeProto>>, pub dynamic_shape_metadata_prefix_bytes: i64, pub split_configs: Vec<SplitConfigProto>,
}
Expand description

A layout describes how the array is placed in (1D) memory space. This includes the minor-to-major ordering of dimensions within a shape.

Clients must specify the layouts of input Literals to the computation. Layouts specified in interior operations which take Shapes (for example, Convert) are ignored.

See the XLA documentation for more information on shapes and layouts.

LINT.IfChange

Fields§

§dim_level_types: Vec<i32>

The dimension level type list for this array, specifying the way in which each array dimension is represented in memory. If this list is empty, the array is assumed to be dense.

§dim_unique: Vec<bool>

Whether each dimension is unique or ordered. Each of the following lists must be empty, or have one entry for each entry of dim_level_types. If either list is empty, all dimensions are assumed to be unique and ordered, respectively. Entries in this list may not be false for some DimLevelType values (such as DIM_DENSE in particular).

§dim_ordered: Vec<bool>§minor_to_major: Vec<i64>

Sequence of dimension numbers, from minor (fastest varying index) to major (slowest varying index). This field is required.

§tiles: Vec<TileProto>

A sequence of tiles, starting from the tile that’s applied first to the Shape.

TODO(b/119839262): implement tiling in each backend or add Unimplemented error.

§tail_padding_alignment_in_elements: i64

The shape is padded at the end to multiple of, in terms of number of elements. This is useful when tiling does not bring the shape to certain desired granules. Tiling effectively pads/reshapes/transposes the shape to another shape. This field pads the total number of elements of that new shape to a multiple of certain number of elements. This is useful such as we want a layout which does not tile the data but still requires it to be padded to certain number of elements.

§element_size_in_bits: i64

(Optional) Bit size of each element. When unspecified or being 0, default to ShapeUtil::ByteSizeOfPrimitiveType.

§memory_space: i64

Memory space where this array resides. The integer field is interpreted in a backend-specific manner.

§index_primitive_type: i32

The integer types to be used for indices and pointers. These fields must not be used unless the layout represents a sparse array. The PrimitiveType must correspond to an unsigned integer (U8, U16, U32, or U64). If not provided, the compiler will use the largest unsigned integer that is naturally supported by the target device (U32 or U64 in currently supported devices).

§pointer_primitive_type: i32§physical_shape: Option<Box<ShapeProto>>

The physical, on-device shape used to represent the shape this layout belongs to. Only used for sparse arrays. The layout(s) contained within the physical shape should not also contain a physical shape.

§dynamic_shape_metadata_prefix_bytes: i64

The dynamic shape metadata size in bytes in front of the shape data. The field may be non-zero for a static shape whose associated buffer is for a dynamic shape, e.g. a result of SliceToDynamic.

§split_configs: Vec<SplitConfigProto>

The split configurations which describe if/how the data is split between different memories.

Implementations§

Source§

impl LayoutProto

Source

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

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

Source

pub fn push_dim_level_types(&mut self, value: DimLevelType)

Appends the provided enum value to dim_level_types.

Source

pub fn index_primitive_type(&self) -> PrimitiveType

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

Source

pub fn set_index_primitive_type(&mut self, value: PrimitiveType)

Sets index_primitive_type to the provided enum value.

Source

pub fn pointer_primitive_type(&self) -> PrimitiveType

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

Source

pub fn set_pointer_primitive_type(&mut self, value: PrimitiveType)

Sets pointer_primitive_type to the provided enum value.

Trait Implementations§

Source§

impl Clone for LayoutProto

Source§

fn clone(&self) -> LayoutProto

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 LayoutProto

Source§

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

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

impl Default for LayoutProto

Source§

fn default() -> Self

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

impl Message for LayoutProto

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 LayoutProto

Source§

fn eq(&self, other: &LayoutProto) -> 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 LayoutProto

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.