Caffe Parser

class tensorrt.IBlobNameToTensor

This class is used to store and query ITensor s after they have been extracted from a Caffe model using the CaffeParser .

find(self: tensorrt.tensorrt.IBlobNameToTensor, name: str) → tensorrt.tensorrt.ITensor

Given a blob name, this function returns an ITensor object.

Parameters:name – Caffe blob name for which the user wants the corresponding ITensor .
Returns:A ITensor object corresponding to the queried name. If no such ITensor exists, then an empty object is returned.
class tensorrt.CaffeParser(self: tensorrt.tensorrt.CaffeParser) → None

This class is used for parsing Caffe models. It allows users to export models trained using Caffe to TRT.

Variables:
  • plugin_factoryICaffePluginFactory The ICaffePluginFactory used to create the user defined plugins.
  • plugin_factory_extICaffePluginFactoryExt The ICaffePluginFactoryExt used to create the user defined pluginExts.
  • plugin_factory_v2ICaffePluginFactoryV2 The ICaffePluginFactory used to create the user defined plugins.
  • plugin_namespacestr The namespace used to lookup and create plugins in the network.
  • protobuf_buffer_sizeint The buffer size for the parsing and storage of the learned model.
__del__(self: tensorrt.tensorrt.CaffeParser) → None
__exit__(exc_type, exc_value, traceback)

Destroy this object, freeing all memory associated with it. This should be called to ensure that the object is cleaned up properly. Equivalent to invoking __del__()

__init__(self: tensorrt.tensorrt.CaffeParser) → None
parse(self: tensorrt.tensorrt.CaffeParser, deploy: str, model: str, network: tensorrt.tensorrt.INetworkDefinition, dtype: tensorrt.tensorrt.DataType) → tensorrt.tensorrt.IBlobNameToTensor

Parse a prototxt file and a binaryproto Caffe model to extract network definition and weights associated with the network, respectively.

Parameters:
  • deploy – The plain text, prototxt file used to define the network definition.
  • model – The binaryproto Caffe model that contains the weights associated with the network.
  • network – Network in which the CaffeParser will fill the layers.
  • dtype – The type to which the weights will be transformed.
Returns:

An IBlobNameToTensor object that contains the extracted data.

parse_binary_proto(self: tensorrt.tensorrt.CaffeParser, filename: str) → array

Parse and extract data stored in binaryproto file. The binaryproto file contains data stored in a binary blob. parse_binary_proto() converts it to an numpy.ndarray object.

Parameters:filename – Path to file containing binary proto.
Returns:numpy.ndarray An array that contains the extracted data.
parse_buffer(self: tensorrt.tensorrt.CaffeParser, deploy_buffer: buffer, model_buffer: buffer, network: tensorrt.tensorrt.INetworkDefinition, dtype: tensorrt.tensorrt.DataType) → tensorrt.tensorrt.IBlobNameToTensor

Parse a prototxt file and a binaryproto Caffe model to extract network definition and weights associated with the network, respectively.

Parameters:
  • deploy_buffer – The memory buffer containing the plain text deploy prototxt used to define the network definition.
  • model_buffer – The binaryproto Caffe memory buffer that contains the weights associated with the network.
  • network – Network in which the CaffeParser will fill the layers.
  • dtype – The type to which the weights will be transformed.
Returns:

An IBlobNameToTensor object that contains the extracted data.

tensorrt.shutdown_protobuf_library() → None

Shuts down protocol buffers library.