TensorRT  7.2.1.6
NVIDIA TensorRT
Looking for a C++ dev who knows TensorRT?
I'm looking for work. Hire me!
generate Namespace Reference

Functions

def propagate_dtype (outputs, dtype)
 
def add (self, a, b)
 
def mul (self, a, b)
 
def gemm (self, a, b, trans_a=False, trans_b=False)
 
def relu (self, a)
 
def min (self, *args)
 
def max (self, *args)
 
def identity (self, inp)
 
def shape (self, a)
 
def reduce_prod (self, a, axes, keepdims=True)
 
def reshape (self, data, shape)
 
def gather (self, data, indices)
 
def concat (self, inputs, axis=0)
 

Variables

tuple shape = (1, 3, 224, 224)
 
 x0 = gs.Variable(name="x0", dtype=np.float32, shape=shape)
 
 x1 = gs.Variable(name="x1", dtype=np.float32, shape=shape)
 
 a = gs.Constant("a", values=np.ones(shape=shape, dtype=np.float32))
 
 b = gs.Constant("b", values=np.ones(shape=shape, dtype=np.float32))
 
 mul_out = gs.Variable(name="mul_out")
 
 add_out = gs.Variable(name="add_out")
 
 Y = gs.Variable(name="Y", dtype=np.float32, shape=shape)
 
list nodes
 
 graph = gs.Graph(nodes=nodes, inputs=[x0, x1], outputs=[Y])
 The functions registered above greatly simplify the process of building the graph itself. More...
 
 input = gs.Variable("input", shape=shape, dtype=np.float32)
 
 c = gs.Variable("c")
 
 d = gs.Constant("d", values=np.ones(shape=shape, dtype=np.float32))
 
 e = gs.Variable("e")
 
 output = gs.Variable("output", shape=shape, dtype=np.float32)
 
 x = gs.Variable(name="x", dtype=np.float32, shape=(1, 3, 224, 224))
 
 i0 = gs.Variable(name="i0")
 
 i1 = gs.Variable(name="i1")
 
 y = gs.Variable(name="y", dtype=np.float32)
 
 X = gs.Variable(name="X", shape=(64, 64), dtype=np.float32)
 
 inputs
 
 A = np.ones(shape=(64, 64), dtype=np.float32)
 
def axt = graph.gemm(A, X, trans_b=True)
 
float B = np.ones((64, 64), dtype=np.float32) * 0.5
 
def dense = graph.relu(*graph.add(*axt, B))
 
 C = gs.Constant(name="C", values=np.ones(shape=(64, 64), dtype=np.float32))
 
 D = np.ones(shape=(64, 64), dtype=np.float32)
 
 outputs
 
 dtype
 
 MIN_VAL = np.array(0, np.float32)
 
 MAX_VAL = np.array(6, np.float32)
 
def inp = graph.identity(graph.inputs[0])
 
def max_out = graph.max(graph.min(inp, MAX_VAL), MIN_VAL)
 
 float32
 
 name
 
def input_shape = graph.shape(graph.inputs[0])
 
def volume = graph.reduce_prod(input_shape, axes=[0])
 
def flattened = graph.reshape(graph.inputs[0], volume)
 
def NC = graph.gather(input_shape, indices=[0, 1])
 
def HW = graph.gather(input_shape, indices=[2, 3])
 
def new_shape = graph.concat([NC, graph.reduce_prod(HW, axes=[0])])
 
def partially_flattened = graph.reshape(graph.inputs[0], new_shape)
 

Function Documentation

◆ propagate_dtype()

def generate.propagate_dtype (   outputs,
  dtype 
)
Here is the caller graph for this function:

◆ add()

def generate.add (   self,
  a,
  b 
)
Here is the call graph for this function:

◆ mul()

def generate.mul (   self,
  a,
  b 
)
Here is the call graph for this function:

◆ gemm()

def generate.gemm (   self,
  a,
  b,
  trans_a = False,
  trans_b = False 
)
Here is the call graph for this function:

◆ relu()

def generate.relu (   self,
  a 
)
Here is the call graph for this function:

◆ min()

def generate.min (   self,
args 
)

◆ max()

def generate.max (   self,
args 
)

◆ identity()

def generate.identity (   self,
  inp 
)

◆ shape()

def generate.shape (   self,
  a 
)

◆ reduce_prod()

def generate.reduce_prod (   self,
  a,
  axes,
  keepdims = True 
)

◆ reshape()

def generate.reshape (   self,
  data,
  shape 
)

◆ gather()

def generate.gather (   self,
  data,
  indices 
)

◆ concat()

def generate.concat (   self,
  inputs,
  axis = 0 
)

Variable Documentation

◆ shape

tuple generate.shape = (1, 3, 224, 224)

◆ x0

generate.x0 = gs.Variable(name="x0", dtype=np.float32, shape=shape)

◆ x1

generate.x1 = gs.Variable(name="x1", dtype=np.float32, shape=shape)

◆ a

generate.a = gs.Constant("a", values=np.ones(shape=shape, dtype=np.float32))

◆ b

generate.b = gs.Constant("b", values=np.ones(shape=shape, dtype=np.float32))

◆ mul_out

generate.mul_out = gs.Variable(name="mul_out")

◆ add_out

generate.add_out = gs.Variable(name="add_out")

◆ Y

generate.Y = gs.Variable(name="Y", dtype=np.float32, shape=shape)

◆ nodes

list generate.nodes
Initial value:
1 = [
2  # mul_out = a * x1
3  gs.Node(op="Mul", inputs=[a, x1], outputs=[mul_out]),
4  # add_out = mul_out + b
5  gs.Node(op="Add", inputs=[mul_out, b], outputs=[add_out]),
6  # Y = x0 + add
7  gs.Node(op="Add", inputs=[x0, add_out], outputs=[Y]),
8 ]

◆ graph

generate.graph = gs.Graph(nodes=nodes, inputs=[x0, x1], outputs=[Y])

The functions registered above greatly simplify the process of building the graph itself.

◆ input

generate.input = gs.Variable("input", shape=shape, dtype=np.float32)

◆ c

generate.c = gs.Variable("c")

◆ d

generate.d = gs.Constant("d", values=np.ones(shape=shape, dtype=np.float32))

◆ e

generate.e = gs.Variable("e")

◆ output

generate.output = gs.Variable("output", shape=shape, dtype=np.float32)

◆ x

generate.x = gs.Variable(name="x", dtype=np.float32, shape=(1, 3, 224, 224))

◆ i0

generate.i0 = gs.Variable(name="i0")

◆ i1

generate.i1 = gs.Variable(name="i1")

◆ y

generate.y = gs.Variable(name="y", dtype=np.float32)

◆ X

generate.X = gs.Variable(name="X", shape=(64, 64), dtype=np.float32)

◆ inputs

generate.inputs

◆ A

generate.A = np.ones(shape=(64, 64), dtype=np.float32)

◆ axt

def generate.axt = graph.gemm(A, X, trans_b=True)

◆ B

float generate.B = np.ones((64, 64), dtype=np.float32) * 0.5

◆ dense

def generate.dense = graph.relu(*graph.add(*axt, B))

◆ C

generate.C = gs.Constant(name="C", values=np.ones(shape=(64, 64), dtype=np.float32))

◆ D

generate.D = np.ones(shape=(64, 64), dtype=np.float32)

◆ outputs

generate.outputs

◆ dtype

generate.dtype

◆ MIN_VAL

generate.MIN_VAL = np.array(0, np.float32)

◆ MAX_VAL

generate.MAX_VAL = np.array(6, np.float32)

◆ inp

def generate.inp = graph.identity(graph.inputs[0])

◆ max_out

def generate.max_out = graph.max(graph.min(inp, MAX_VAL), MIN_VAL)

◆ float32

generate.float32

◆ name

generate.name

◆ input_shape

def generate.input_shape = graph.shape(graph.inputs[0])

◆ volume

def generate.volume = graph.reduce_prod(input_shape, axes=[0])

◆ flattened

def generate.flattened = graph.reshape(graph.inputs[0], volume)

◆ NC

def generate.NC = graph.gather(input_shape, indices=[0, 1])

◆ HW

def generate.HW = graph.gather(input_shape, indices=[2, 3])

◆ new_shape

def generate.new_shape = graph.concat([NC, graph.reduce_prod(HW, axes=[0])])

◆ partially_flattened

def generate.partially_flattened = graph.reshape(graph.inputs[0], new_shape)