Struct TensorRTBlobHeader#

Struct Documentation#

struct TensorRTBlobHeader#

Where the metadata and engine live inside a TR01/TR02/TR03 blob, and what the metadata said.

Public Members

uint32_t metadata_offset = 0#

Byte offset of the JSON metadata; never inside the header.

uint32_t metadata_size = 0#

Length of the JSON metadata in bytes.

uint32_t engine_offset = 0#

Byte offset of the serialized engine; 16-byte aligned.

uint64_t engine_size = 0#

Length of the serialized engine in bytes.

std::vector<std::string> input_binding_names#

TensorRT input binding names, in the order the metadata lists them.

std::vector<std::string> output_binding_names#

TensorRT output binding names, in the order the metadata lists them.

std::vector<AliasedBinding> aliased_io#

Aliased output->input binding pairs declared by the metadata.

bool hardware_compatible = false#

Engine built hardware-compatible; false when unstated.

int device_id = 0#

Device the engine was built for; 0 when unstated.

std::string engine_key#

Named-data key of an engine stored outside the blob; empty when it is inline.

std::string tensorrt_version#

TensorRT version that exported the engine; empty when the blob does not say.

Public Static Functions

static const void *engine_data(const void *blob, const TensorRTBlobHeader &h)#

Start of the serialized engine inside a blob.

Parameters:
  • blob – Start of the processed blob h was parsed from.

  • h – Header parsed from that blob.

Returns:

Pointer to TensorRTBlobHeader::engine_size bytes of engine data.

static bool parse(const void *data, std::size_t size, TensorRTBlobHeader &out)#

Validates a processed blob and reads its header.

Checks the TR01, TR02 or TR03 magic, that the metadata and the engine both lie within size, that the engine is 16-byte aligned, and that the metadata ends at or before the engine; then reads the binding names and flags out of the JSON. A TR02 blob whose metadata yields no aliased_io entries is rejected, since running it would silently stop updating the caller’s buffers; a TR01 blob that does carry them is accepted and read as aliased. A blob must carry exactly one of an inline engine and an engine_key, and the key exactly when the magic is TR03.

Parameters:
  • data – Start of the processed blob.

  • size – Bytes available at data.

  • out – [out] Filled in on success; left in an unspecified state otherwise.

Returns:

false when the blob is not a well-formed TR01/TR02/TR03 blob.