tvm.contrib.graph_runtime

Minimum graph runtime that executes graph containing TVM PackedFunc.

class tvm.contrib.graph_runtime.GraphModule(module, ctx)

Wrapper runtime module.

This is a thin wrapper of the underlying TVM module. you can also directly call set_input, run, and get_output of underlying module functions

Parameters:
  • module (Module) – The interal tvm module that holds the actual graph functions.
  • ctx (TVMContext) – The context this module is under
module

Module – The interal tvm module that holds the actual graph functions.

ctx

TVMContext – The context this module is under

debug_get_output(node, out)

Run graph upto node and get the output to out

Parameters:
  • node (int / str) – The node index or name
  • out (NDArray) – The output array container
get_input(index, out)

Get index-th input to out

Parameters:
  • index (int) – The input index
  • out (NDArray) – The output array container
get_output(index, out)

Get index-th output to out

Parameters:
  • index (int) – The input index
  • out (NDArray) – The output array container
load_params(params_bytes)

Load parameters from serialized byte array of parameter dict.

Parameters:params_bytes (bytearray) – The serialized parameter dict.
run(**input_dict)

Run forward execution of the graph

Parameters:input_dict (dict of str to NDArray) – List of input values to be feed to
set_input(key=None, value=None, **params)

Set inputs to the module via kwargs

Parameters:
  • key (int or str) – The input key
  • value (the input value.) – The input key
  • params (dict of str to NDArray) – Additonal arguments
tvm.contrib.graph_runtime.create(graph_json_str, libmod, ctx)

Create a runtime executor module given a graph and module.

Parameters:
  • graph_json_str (str or graph class) – The graph to be deployed in json format output by nnvm graph. The graph can only contain one operator(tvm_op) that points to the name of PackedFunc in the libmod.
  • libmod (tvm.Module) – The module of the corresponding function
  • ctx (TVMContext) – The context to deploy the module, can be local or remote.
Returns:

graph_module – Runtime graph module that can be used to execute the graph.

Return type:

GraphModule