Writer

lamp.data.Writer$
object Writer

Serializes tensors

This format is similar to the ONNX external tensor serialization format, but it uses JSON rather then protobuf.

==Format specification==

Sequences of tensors are serialized into a JSON descriptor and a data blob. The schema of the descriptor is the case class lamp.data.schemas.TensorList. The location field in this schema holds a path to the data blob. If this is a relative POSIX path then it is relative to the file path where the descriptor itself is written. Otherwise it is an absolute path of the data blob file.

The descriptor may be embedded into larger JSON structures.

The data blob itself is the raw data in little endian byte order. Floating point is IEEE-754. The descriptor specifies the byte offset and byte length of the tensors inside the data blob. As such, the data blob contains no framing or other control bytes, but it may contain padding bytes between tensors.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Writer.type

Members list

Value members

Concrete methods

def writeCheckpoint[A, B](file: File, model: GenericModule[A, B], bufferSize: Int): IO[Either[String, Unit]]
def writeTensorDataIntoChannel(tensors: Seq[STen], channel: WritableByteChannel, bufferSize: Int): Seq[(Long, Long, Long)]

Returns list of (offset, length) in bytes

Returns list of (offset, length) in bytes

Attributes

def writeTensorsIntoFile(tensors: Seq[STen], file: File, bufferSize: Int): IO[Either[String, Unit]]