Skip to main content

Attribute

Enum Attribute 

Source
pub enum Attribute {
Show 14 variants Int(i64), Float(f32), String(Vec<u8>), Ints(Vec<i64>), Floats(Vec<f32>), Strings(Vec<Vec<u8>>), Tensor(TensorData), Tensors(Vec<TensorData>), SparseTensor(SparseTensorData), SparseTensors(Vec<SparseTensorData>), Graph(Box<Graph>), Graphs(Vec<Graph>), TypeProto(TypeProto), TypeProtos(Vec<TypeProto>),
}
Expand description

An ONNX operator attribute. Covers all attribute value kinds.

Variants§

§

Int(i64)

§

Float(f32)

§

String(Vec<u8>)

An ONNX STRING attribute. Stored as raw bytes, not String, so that the load/dump path round-trips the payload byte-exactly: ONNX STRING attributes are arbitrary byte strings (e.g. an opaque compiled blob) that are not guaranteed to be valid UTF-8. Use Attribute::as_str to view the bytes as UTF-8 text when that is meaningful.

§

Ints(Vec<i64>)

§

Floats(Vec<f32>)

§

Strings(Vec<Vec<u8>>)

An ONNX STRINGS attribute — a list of raw byte strings (see Attribute::String for why bytes rather than String).

§

Tensor(TensorData)

§

Tensors(Vec<TensorData>)

§

SparseTensor(SparseTensorData)

§

SparseTensors(Vec<SparseTensorData>)

§

Graph(Box<Graph>)

A subgraph body (control-flow ops: If/Loop/Scan). Stored inline; the owning Graph also indexes it in subgraphs for traversal.

§

Graphs(Vec<Graph>)

§

TypeProto(TypeProto)

§

TypeProtos(Vec<TypeProto>)

Implementations§

Source§

impl Attribute

Source

pub fn as_int(&self) -> Option<i64>

The i64 value, if this is an Attribute::Int.

Source

pub fn as_float(&self) -> Option<f32>

The f32 value, if this is an Attribute::Float.

Source

pub fn as_str(&self) -> Option<&str>

The value as UTF-8 text, if this is an Attribute::String whose bytes are valid UTF-8. Returns None for a non-string attribute or for string bytes that are not valid UTF-8 (e.g. an opaque binary payload).

Source

pub fn as_bytes(&self) -> Option<&[u8]>

The raw bytes of an Attribute::String, regardless of whether they are valid UTF-8. Returns None for any other attribute kind.

Source

pub fn as_ints(&self) -> Option<&[i64]>

The &[i64] slice, if this is an Attribute::Ints.

Source

pub fn as_shape(&self) -> Option<Shape>

Interpret an Ints attribute as a shape of static dims.

Trait Implementations§

Source§

impl Clone for Attribute

Source§

fn clone(&self) -> Attribute

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Attribute

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.