pub struct TensorProto {Show 14 fields
pub dims: Vec<i64>,
pub data_type: i32,
pub segment: Option<Segment>,
pub float_data: Vec<f32>,
pub int32_data: Vec<i32>,
pub string_data: Vec<Vec<u8>>,
pub int64_data: Vec<i64>,
pub name: String,
pub doc_string: String,
pub raw_data: Vec<u8>,
pub external_data: Vec<StringStringEntryProto>,
pub data_location: i32,
pub double_data: Vec<f64>,
pub uint64_data: Vec<u64>,
}
Expand description
Tensors
A serialized tensor value.
Fields§
§dims: Vec<i64>
The shape of the tensor.
data_type: i32
The data type of the tensor. This field MUST have a valid TensorProto.DataType value
segment: Option<Segment>
§float_data: Vec<f32>
For float and complex64 values Complex64 tensors are encoded as a single array of floats, with the real components appearing in odd numbered positions, and the corresponding imaginary component apparing in the subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i] is encoded as [1.0, 2.0 ,3.0 ,4.0] When this field is present, the data_type field MUST be FLOAT or COMPLEX64.
int32_data: Vec<i32>
For int32, uint8, int8, uint16, int16, bool, and float16 values float16 values must be bit-wise converted to an uint16_t prior to writing to the buffer. When this field is present, the data_type field MUST be INT32, INT16, INT8, UINT16, UINT8, BOOL, or FLOAT16
string_data: Vec<Vec<u8>>
For strings. Each element of string_data is a UTF-8 encoded Unicode string. No trailing null, no leading BOM. The protobuf “string” scalar type is not used to match ML community conventions. When this field is present, the data_type field MUST be STRING
int64_data: Vec<i64>
For int64. When this field is present, the data_type field MUST be INT64
name: String
Optionally, a name for the tensor.
namespace Value
doc_string: String
A human-readable documentation for this tensor. Markdown is allowed.
raw_data: Vec<u8>
Serializations can either use one of the fields above, or use this raw bytes field. The only exception is the string case, where one is required to store the content in the repeated bytes string_data field.
When this raw_data field is used to store tensor value, elements MUST be stored in as fixed-width, little-endian order. Floating-point data types MUST be stored in IEEE 754 format. Complex64 elements must be written as two consecutive FLOAT values, real component first. Complex128 elements must be written as two consecutive DOUBLE values, real component first. Boolean type MUST be written one byte per tensor element (00000001 for true, 00000000 for false).
Note: the advantage of specific field rather than the raw_data field is that in some cases (e.g. int data), protobuf does a better packing via variable length storage, and may lead to smaller binary footprint. When this field is present, the data_type field MUST NOT be STRING or UNDEFINED
external_data: Vec<StringStringEntryProto>
Data can be stored inside the protobuf file using type-specific fields or raw_data. Alternatively, raw bytes data can be stored in an external file, using the external_data field. external_data stores key-value pairs describing data location. Recognized keys are:
- “location” (required) - POSIX filesystem path relative to the directory where the ONNX protobuf model was stored
- “offset” (optional) - position of byte at which stored data begins. Integer stored as string. Offset values SHOULD be multiples 4096 (page size) to enable mmap support.
- “length” (optional) - number of bytes containing data. Integer stored as string.
- “checksum” (optional) - SHA1 digest of file specified in under ‘location’ key.
data_location: i32
If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
double_data: Vec<f64>
For double Complex128 tensors are encoded as a single array of doubles, with the real components appearing in odd numbered positions, and the corresponding imaginary component apparing in the subsequent even numbered position. (e.g., [1.0 + 2.0i, 3.0 + 4.0i] is encoded as [1.0, 2.0 ,3.0 ,4.0] When this field is present, the data_type field MUST be DOUBLE or COMPLEX128
uint64_data: Vec<u64>
For uint64 and uint32 values When this field is present, the data_type field MUST be UINT32 or UINT64
Implementations§
Source§impl TensorProto
impl TensorProto
Sourcepub fn data_location(&self) -> DataLocation
pub fn data_location(&self) -> DataLocation
Returns the enum value of data_location
, or the default if the field is set to an invalid enum value.
Sourcepub fn set_data_location(&mut self, value: DataLocation)
pub fn set_data_location(&mut self, value: DataLocation)
Sets data_location
to the provided enum value.
Trait Implementations§
Source§impl Clone for TensorProto
impl Clone for TensorProto
Source§fn clone(&self) -> TensorProto
fn clone(&self) -> TensorProto
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for TensorProto
impl Debug for TensorProto
Source§impl Default for TensorProto
impl Default for TensorProto
Source§fn default() -> TensorProto
fn default() -> TensorProto
Source§impl From<TensorProto> for Attribute
impl From<TensorProto> for Attribute
Source§fn from(v: TensorProto) -> Self
fn from(v: TensorProto) -> Self
Source§impl From<f32> for TensorProto
impl From<f32> for TensorProto
Source§fn from(data: f32) -> TensorProto
fn from(data: f32) -> TensorProto
Source§impl From<f64> for TensorProto
impl From<f64> for TensorProto
Source§fn from(data: f64) -> TensorProto
fn from(data: f64) -> TensorProto
Source§impl From<i32> for TensorProto
impl From<i32> for TensorProto
Source§fn from(data: i32) -> TensorProto
fn from(data: i32) -> TensorProto
Source§impl From<i64> for TensorProto
impl From<i64> for TensorProto
Source§fn from(data: i64) -> TensorProto
fn from(data: i64) -> TensorProto
Source§impl From<u64> for TensorProto
impl From<u64> for TensorProto
Source§fn from(data: u64) -> TensorProto
fn from(data: u64) -> TensorProto
Source§impl Message for TensorProto
impl Message for TensorProto
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
fn encode_length_delimited<B>(&self, buf: &mut B) -> Result<(), EncodeError>
Source§fn decode<B>(buf: B) -> Result<Self, DecodeError>
fn decode<B>(buf: B) -> Result<Self, DecodeError>
Source§fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
fn decode_length_delimited<B>(buf: B) -> Result<Self, DecodeError>
Source§fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
. Read moreSource§fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
fn merge_length_delimited<B>(&mut self, buf: B) -> Result<(), DecodeError>
self
.