Class TensorProto
Tensors
A serialized tensor value.
Namespace: Onnx
Syntax
public sealed class TensorProto : Google.Protobuf.IMessage<TensorProto>
Constructors
TensorProto()
Declaration
TensorProto(TensorProto)
Declaration
public TensorProto(TensorProto other)
Parameters
Fields
DataLocationFieldNumber
Field number for the "data_location" field.
Declaration
public const int DataLocationFieldNumber = 14
Field Value
DataTypeFieldNumber
Field number for the "data_type" field.
Declaration
public const int DataTypeFieldNumber = 2
Field Value
DimsFieldNumber
Field number for the "dims" field.
Declaration
public const int DimsFieldNumber = 1
Field Value
DocStringFieldNumber
Field number for the "doc_string" field.
Declaration
public const int DocStringFieldNumber = 12
Field Value
DoubleDataFieldNumber
Field number for the "double_data" field.
Declaration
public const int DoubleDataFieldNumber = 10
Field Value
ExternalDataFieldNumber
Field number for the "external_data" field.
Declaration
public const int ExternalDataFieldNumber = 13
Field Value
FloatDataFieldNumber
Field number for the "float_data" field.
Declaration
public const int FloatDataFieldNumber = 4
Field Value
Int32DataFieldNumber
Field number for the "int32_data" field.
Declaration
public const int Int32DataFieldNumber = 5
Field Value
Int64DataFieldNumber
Field number for the "int64_data" field.
Declaration
public const int Int64DataFieldNumber = 7
Field Value
NameFieldNumber
Field number for the "name" field.
Declaration
public const int NameFieldNumber = 8
Field Value
RawDataFieldNumber
Field number for the "raw_data" field.
Declaration
public const int RawDataFieldNumber = 9
Field Value
SegmentFieldNumber
Field number for the "segment" field.
Declaration
public const int SegmentFieldNumber = 3
Field Value
StringDataFieldNumber
Field number for the "string_data" field.
Declaration
public const int StringDataFieldNumber = 6
Field Value
Uint64DataFieldNumber
Field number for the "uint64_data" field.
Declaration
public const int Uint64DataFieldNumber = 11
Field Value
Properties
DataLocation
If value not set, data is stored in raw_data (if set) otherwise in type-specified field.
Declaration
public TensorProto.Types.DataLocation DataLocation { get; set; }
Property Value
DataType
The data type of the tensor.
This field MUST have a valid TensorProto.DataType value
Declaration
public int DataType { get; set; }
Property Value
Descriptor
Declaration
public static Google.Protobuf.Reflection.MessageDescriptor Descriptor { get; }
Property Value
Type |
Description |
Google.Protobuf.Reflection.MessageDescriptor |
|
Dims
Declaration
public Google.Protobuf.Collections.RepeatedField<long> Dims { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Int64> |
|
DocString
A human-readable documentation for this tensor. Markdown is allowed.
Declaration
public string DocString { get; set; }
Property Value
DoubleData
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
Declaration
public Google.Protobuf.Collections.RepeatedField<double> DoubleData { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Double> |
|
ExternalData
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.
Declaration
public Google.Protobuf.Collections.RepeatedField<StringStringEntryProto> ExternalData { get; }
Property Value
FloatData
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.
Declaration
public Google.Protobuf.Collections.RepeatedField<float> FloatData { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Single> |
|
Int32Data
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
Declaration
public Google.Protobuf.Collections.RepeatedField<int> Int32Data { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Int32> |
|
Int64Data
For int64.
When this field is present, the data_type field MUST be INT64
Declaration
public Google.Protobuf.Collections.RepeatedField<long> Int64Data { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Int64> |
|
Name
Optionally, a name for the tensor.
Declaration
public string Name { get; set; }
Property Value
Parser
Declaration
public static Google.Protobuf.MessageParser<TensorProto> Parser { get; }
Property Value
Type |
Description |
Google.Protobuf.MessageParser<TensorProto> |
|
RawData
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
Declaration
public Google.Protobuf.ByteString RawData { get; set; }
Property Value
Type |
Description |
Google.Protobuf.ByteString |
|
Segment
Declaration
public TensorProto.Types.Segment Segment { get; set; }
Property Value
StringData
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
Declaration
public Google.Protobuf.Collections.RepeatedField<Google.Protobuf.ByteString> StringData { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<Google.Protobuf.ByteString> |
|
Uint64Data
For uint64 and uint32 values
When this field is present, the data_type field MUST be
UINT32 or UINT64
Declaration
public Google.Protobuf.Collections.RepeatedField<ulong> Uint64Data { get; }
Property Value
Type |
Description |
Google.Protobuf.Collections.RepeatedField<UInt64> |
|
Methods
CalculateSize()
Declaration
public int CalculateSize()
Returns
Clone()
Declaration
public TensorProto Clone()
Returns
Equals(TensorProto)
Declaration
public bool Equals(TensorProto other)
Parameters
Returns
Equals(Object)
Declaration
public override bool Equals(object other)
Parameters
Type |
Name |
Description |
Object |
other |
|
Returns
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Declaration
public void MergeFrom(Google.Protobuf.CodedInputStream input)
Parameters
Type |
Name |
Description |
Google.Protobuf.CodedInputStream |
input |
|
MergeFrom(TensorProto)
Declaration
public void MergeFrom(TensorProto other)
Parameters
ToString()
Declaration
public override string ToString()
Returns
WriteTo(Google.Protobuf.CodedOutputStream)
Declaration
public void WriteTo(Google.Protobuf.CodedOutputStream output)
Parameters
Type |
Name |
Description |
Google.Protobuf.CodedOutputStream |
output |
|