Class TensorProto | Barracuda | 0.5.0-preview
docs.unity3d.com
    Show / Hide Table of Contents

    Class TensorProto

    Tensors

    A serialized tensor value.

    Inheritance
    Object
    TensorProto
    Namespace: Onnx
    Syntax
    public sealed class TensorProto : Google.Protobuf.IMessage<TensorProto>

    Constructors

    TensorProto()

    Declaration
    public TensorProto()

    TensorProto(TensorProto)

    Declaration
    public TensorProto(TensorProto other)
    Parameters
    Type Name Description
    TensorProto other

    Fields

    DataLocationFieldNumber

    Field number for the "data_location" field.

    Declaration
    public const int DataLocationFieldNumber = 14
    Field Value
    Type Description
    Int32

    DataTypeFieldNumber

    Field number for the "data_type" field.

    Declaration
    public const int DataTypeFieldNumber = 2
    Field Value
    Type Description
    Int32

    DimsFieldNumber

    Field number for the "dims" field.

    Declaration
    public const int DimsFieldNumber = 1
    Field Value
    Type Description
    Int32

    DocStringFieldNumber

    Field number for the "doc_string" field.

    Declaration
    public const int DocStringFieldNumber = 12
    Field Value
    Type Description
    Int32

    DoubleDataFieldNumber

    Field number for the "double_data" field.

    Declaration
    public const int DoubleDataFieldNumber = 10
    Field Value
    Type Description
    Int32

    ExternalDataFieldNumber

    Field number for the "external_data" field.

    Declaration
    public const int ExternalDataFieldNumber = 13
    Field Value
    Type Description
    Int32

    FloatDataFieldNumber

    Field number for the "float_data" field.

    Declaration
    public const int FloatDataFieldNumber = 4
    Field Value
    Type Description
    Int32

    Int32DataFieldNumber

    Field number for the "int32_data" field.

    Declaration
    public const int Int32DataFieldNumber = 5
    Field Value
    Type Description
    Int32

    Int64DataFieldNumber

    Field number for the "int64_data" field.

    Declaration
    public const int Int64DataFieldNumber = 7
    Field Value
    Type Description
    Int32

    NameFieldNumber

    Field number for the "name" field.

    Declaration
    public const int NameFieldNumber = 8
    Field Value
    Type Description
    Int32

    RawDataFieldNumber

    Field number for the "raw_data" field.

    Declaration
    public const int RawDataFieldNumber = 9
    Field Value
    Type Description
    Int32

    SegmentFieldNumber

    Field number for the "segment" field.

    Declaration
    public const int SegmentFieldNumber = 3
    Field Value
    Type Description
    Int32

    StringDataFieldNumber

    Field number for the "string_data" field.

    Declaration
    public const int StringDataFieldNumber = 6
    Field Value
    Type Description
    Int32

    Uint64DataFieldNumber

    Field number for the "uint64_data" field.

    Declaration
    public const int Uint64DataFieldNumber = 11
    Field Value
    Type Description
    Int32

    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
    Type Description
    TensorProto.Types.DataLocation

    DataType

    The data type of the tensor. This field MUST have a valid TensorProto.DataType value

    Declaration
    public int DataType { get; set; }
    Property Value
    Type Description
    Int32

    Descriptor

    Declaration
    public static Google.Protobuf.Reflection.MessageDescriptor Descriptor { get; }
    Property Value
    Type Description
    Google.Protobuf.Reflection.MessageDescriptor

    Dims

    The shape of the tensor.

    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
    Type Description
    String

    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
    Type Description
    Google.Protobuf.Collections.RepeatedField<StringStringEntryProto>

    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
    Type Description
    String

    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
    Type Description
    TensorProto.Types.Segment

    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
    Type Description
    Int32

    Clone()

    Declaration
    public TensorProto Clone()
    Returns
    Type Description
    TensorProto

    Equals(TensorProto)

    Declaration
    public bool Equals(TensorProto other)
    Parameters
    Type Name Description
    TensorProto other
    Returns
    Type Description
    Boolean

    Equals(Object)

    Declaration
    public override bool Equals(object other)
    Parameters
    Type Name Description
    Object other
    Returns
    Type Description
    Boolean

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    MergeFrom(Google.Protobuf.CodedInputStream)

    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
    Type Name Description
    TensorProto other

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    String

    WriteTo(Google.Protobuf.CodedOutputStream)

    Declaration
    public void WriteTo(Google.Protobuf.CodedOutputStream output)
    Parameters
    Type Name Description
    Google.Protobuf.CodedOutputStream output
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023