TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
chptToBin Namespace Reference

Functions

def chpt_to_dict_arrays_simple (file_name)
 
def chpt_to_dict_arrays ()
 
def concatenate_layers (params)
 
def convert_rnn_kernel (weights, dimensions, is_decoder_rnn=False)
 
def convert_rnn_bias (weights, dimensions, forget_bias=1.0)
 
def convert_weigts (dimensions, data, forget_bias=1.0)
 
def save_layer_weights (data, list_keys, dims, footer_string, file_name)
 
def main (_)
 

Function Documentation

◆ chpt_to_dict_arrays_simple()

def chptToBin.chpt_to_dict_arrays_simple (   file_name)
    Convert a checkpoint into into a dictionary of numpy arrays
    for later use in TensorRT NMT sample.

◆ chpt_to_dict_arrays()

def chptToBin.chpt_to_dict_arrays ( )
    Convert a checkpoint into a dictionary of numpy arrays
    for later use in TensorRT NMT sample.
    git clone https://github.com/tensorflow/nmt.git
Here is the caller graph for this function:

◆ concatenate_layers()

def chptToBin.concatenate_layers (   params)
Concatenate weights from multiple layers
Here is the caller graph for this function:

◆ convert_rnn_kernel()

def chptToBin.convert_rnn_kernel (   weights,
  dimensions,
  is_decoder_rnn = False 
)
In place. weights conversion
TensorFlow weight parameters for BasicLSTMCell
are formatted as:
Each [WR][icfo] is hiddenSize sequential elements.
CellN  Row 0: WiT, WcT, WfT, WoT
CellN  Row 1: WiT, WcT, WfT, WoT
...
CellN RowM-1: WiT, WcT, WfT, WoT
CellN RowM+0: RiT, RcT, RfT, RoT
CellN RowM+1: RiT, RcT, RfT, RoT
...
CellNRow(M+P)-1: RiT, RcT, RfT, RoT
M - data size
P - projection size
TensorRT expects the format to laid out in memory:
CellN: Wf, Wi, Wc, Wo, Rf, Ri, Rc, Ro

For the purpose of implementing LSTMP all W and R weights become weights from W
CellN: Wf, Rf, Wi, Ri, Wc, Rc, Wo, Ro, Empty states

Update: alternative notation
Tensorflow documents gates' order in e.g.
https:github.com/tensorflow/tensorflow/blob/r1.4/tensorflow/python/ops/rnn_cell_impl.py:439
TF: i = input_gate, j = new_input (cell gate), f = forget_gate, o = output_gate - ijfo
Need to convert 'ijfo' to 'fijo'
Here is the caller graph for this function:

◆ convert_rnn_bias()

def chptToBin.convert_rnn_bias (   weights,
  dimensions,
  forget_bias = 1.0 
)
TensorFlow bias parameters for BasicLSTMCell
are formatted as:
CellN: Bi, Bc, Bf, Bo

TensorRT expects the format to be:
CellN: Wf, Wi, Wc, Wo, Rf, Ri, Rc, Ro

Since Tensorflow already combines U and W,
we double the size and set all of U to zero.
Here is the caller graph for this function:

◆ convert_weigts()

def chptToBin.convert_weigts (   dimensions,
  data,
  forget_bias = 1.0 
)
Convert weights from Tensorflow to TensorRT format
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_layer_weights()

def chptToBin.save_layer_weights (   data,
  list_keys,
  dims,
  footer_string,
  file_name 
)
    data          - dictionary with string names as keys and
                    numpy weights as values
    list_keys     - list of dictionary keys to save
    dims          - list of int values relevant to the layer
                    e.g. tensor dimensions sufficient to extract all the tensors
    footer_string - marker placed at the end of file

    file format: data -> meta_data -> footer
Here is the caller graph for this function:

◆ main()

def chptToBin.main (   _)
Here is the call graph for this function: