Hello. I’m a fresh user of TVM. In order to have a hashtable init along with graph runtime, I want to:
- split the HashTableV2 CallNodes in the graph which output is connecting with the LookupTableFindV2 CallNode.
- Change the LookupTableFindV2 node’s input with the Var.
- (a) create a new CallNode(op_name=table_initialize), the inputs are all the HashTableV2 CallNodes.
- (a) Let the table_initialize CallNode be the output of a new global func “init”.
- (b) create a new relay.Function, the inputs are al the HashTableV2 CallNodes.
- (b) Let the new function be the new global func
- The module has two funcs: main and init.
- Codegen for each func: main and init.
Please note that 3-4 and 5-6 are two alternatives. But I encountered a problem when adding a new Function. (take 5-6)
g._hashtable_nodes is all the hashtable nodes: I added an _expr.var here which is wrong. How can I add a _expr.Call (or a CallNode) for each HashTableV2 node?
if "HashTableV2" in node.op:
self._hashtable_nodes.append(_expr.var(node.name, shape=(1, 1), dtype="object"))
main_func, params = g.from_tensorflow(graph_def,
layout,
shape,
outputs,
gdef_lib=graph_def_library,
init_phase=False)
module.mod["main"] = main_func
module.params.update(params)
if len(g._hashtable_nodes):
data_shape = (1, 1)
data = tvm.relay.var("data", tvm.relay.TensorType(data_shape, "object"))
init_func = tvm.relay.Function(g._hashtable_nodes, g._hashtable_nodes[0])
module.mod["init"] = init_func
The topo is something like this: C is the HashTableV2 node. Op is the new Function or CallNode.