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
impl Attribute
Sourcepub fn as_int(&self) -> Option<i64>
pub fn as_int(&self) -> Option<i64>
The i64 value, if this is an Attribute::Int.
Sourcepub fn as_float(&self) -> Option<f32>
pub fn as_float(&self) -> Option<f32>
The f32 value, if this is an Attribute::Float.
Sourcepub fn as_str(&self) -> Option<&str>
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).
Sourcepub fn as_bytes(&self) -> Option<&[u8]>
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.
Sourcepub fn as_ints(&self) -> Option<&[i64]>
pub fn as_ints(&self) -> Option<&[i64]>
The &[i64] slice, if this is an Attribute::Ints.