TensorProto

onnx.onnx.TensorProto
See theTensorProto companion object
final case class TensorProto(dims: Seq[Long], dataType: Option[Int], segment: Option[Segment], floatData: Seq[Float], int32Data: Seq[Int], stringData: Seq[ByteString], int64Data: Seq[Long], name: Option[String], docString: Option[String], rawData: Option[ByteString], externalData: Seq[StringStringEntryProto], dataLocation: Option[DataLocation], doubleData: Seq[Double], uint64Data: Seq[Long], unknownFields: UnknownFieldSet) extends GeneratedMessage, Updatable[TensorProto]

Tensors

A serialized tensor value.

Value parameters

dataLocation

If value not set, data is stored in raw_data (if set) otherwise in type-specified field.

dataType

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

dims

The shape of the tensor.

docString

A human-readable documentation for this tensor. Markdown is allowed.

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 appearing 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

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.
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 appearing 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.

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

int64Data

For int64. When this field is present, the data_type field MUST be INT64

name

Optionally, a name for the tensor. namespace Value

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

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

uint64Data

For uint64 and uint32 values When this field is present, the data_type field MUST be UINT32 or UINT64

Attributes

Companion
object
Graph
Supertypes
trait Updatable[TensorProto]
trait GeneratedMessage
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def addAllDims(`__vs`: Iterable[Long]): TensorProto
def addAllDoubleData(`__vs`: Iterable[Double]): TensorProto
def addAllFloatData(`__vs`: Iterable[Float]): TensorProto
def addAllInt32Data(`__vs`: Iterable[Int]): TensorProto
def addAllInt64Data(`__vs`: Iterable[Long]): TensorProto
def addAllStringData(`__vs`: Iterable[ByteString]): TensorProto
def addAllUint64Data(`__vs`: Iterable[Long]): TensorProto
def addDims(`__vs`: Long*): TensorProto
def addDoubleData(`__vs`: Double*): TensorProto
def addFloatData(`__vs`: Float*): TensorProto
def addInt32Data(`__vs`: Int*): TensorProto
def addInt64Data(`__vs`: Long*): TensorProto
def addStringData(`__vs`: ByteString*): TensorProto
def addUint64Data(`__vs`: Long*): TensorProto
def getDataType: Int
def getDocString: String
def getField(`__field`: FieldDescriptor): PValue
def getFieldByNumber(`__fieldNumber`: Int): Any
def getName: String
def getRawData: ByteString
override def serializedSize: Int

Attributes

Definition Classes
GeneratedMessage
def toProtoString: String

Returns a human-readable ASCII format representation of this message.

Returns a human-readable ASCII format representation of this message.

The original message can be decoded from this format by using fromAscii on the companion object.

Attributes

Returns

human-readable representation of this message.

def withDataType(`__v`: Int): TensorProto
def withDims(`__v`: Seq[Long]): TensorProto
def withDocString(`__v`: String): TensorProto
def withDoubleData(`__v`: Seq[Double]): TensorProto
def withFloatData(`__v`: Seq[Float]): TensorProto
def withInt32Data(`__v`: Seq[Int]): TensorProto
def withInt64Data(`__v`: Seq[Long]): TensorProto
def withName(`__v`: String): TensorProto
def withRawData(`__v`: ByteString): TensorProto
def withStringData(`__v`: Seq[ByteString]): TensorProto
def withUint64Data(`__v`: Seq[Long]): TensorProto
def withUnknownFields(`__v`: UnknownFieldSet): TensorProto
def writeTo(`_output__`: CodedOutputStream): Unit

Serializes the message into the given coded output stream

Serializes the message into the given coded output stream

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product
final def toByteArray: Array[Byte]

Serializes the message and returns a byte array containing its raw bytes

Serializes the message and returns a byte array containing its raw bytes

Attributes

Inherited from:
GeneratedMessage
final def toByteString: ByteString

Serializes the message and returns a ByteString containing its raw bytes

Serializes the message and returns a ByteString containing its raw bytes

Attributes

Inherited from:
GeneratedMessage
final def toPMessage: PMessage

Attributes

Inherited from:
GeneratedMessage
def update(ms: Lens[TensorProto, TensorProto] => () => TensorProto*): A

Attributes

Inherited from:
Updatable
final def writeDelimitedTo(output: OutputStream): Unit

Attributes

Inherited from:
GeneratedMessage
final def writeTo(output: OutputStream): Unit

Serializes the message into the given output stream

Serializes the message into the given output stream

Attributes

Inherited from:
GeneratedMessage