You can load the frozen pb file which gives you the graph, then convert the graph to DynamicGraph and modify it. So something like this (probably not runnable directly):
import tensorflow as tf
from tensorflow.core.framework import types_pb2
import graphsurgeon as gs
# Load the graph
graph = tf.Graph()
with tf.gfile.GFile(frozen_graph_filename, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
tf.import_graph_def(graph_def, name='')
graph = gs.DynamicGraph(graph)
# Add new node
node = tf.NodeDef()
node.op = 'my-custom-operation'
node.name = 'my-custom-node'
graph.append(node)
# Now the new node is disconnected from rest of the graph
# Modify existing graph to point to the new node
# Modification is done by changing input lists which contain names of input nodes
next = graph.find_nodes_by_name('next_node')[0] # assume only one node is found
node.input = next.input
next.input = [node.name]
I suggest that you inspect graphs created by the TRT examples just before they are written to UFF file.