Hi,
I have a function that will return an implementation of a composite using TE as a runtime module. Imagine that the block is something of the like
%0 = nn.conv2d(%x, meta[relay.Constant] #weights, ...)
%1 = nn.bias_add(%0, meta[relay.Constant] #biases ...)
and I have generated a custom implementation of this using TE. Now in this implementation, I set up placeholders for all the variables. For example, I have
weights = te.placeholder(weights_shape, name="weights")
which I then use in a TE expression implementing that composite block.
I end up with a list like this
te_list = [input, weights, bias, result]
that I can lower to a runtime module by doing
schedule = te.create_schedule(result.op)
runtime_mod = tvm.build(schedule, te_list, target="llvm")
Now my problem is the following. If I want to use the runtime_mod, I need to pass all the inputs including the weights and biases.
output = runtime_mod(data_arr, weights_arr, bias_arr)
However, I already know the value of the weights and bias at compile-time, as shown in the pseudo-relay previously. What is the best way then to handle binding these constant weights and bias to the runtime module? Is there such concept of partial application of a runtime module where I would do something like the following?
def wrapped_runtime_mod(runtime_mod)
weights_vals = const_arr
bias_vals = const_arr
return runtime_mod(weights=weights_vals, bias=bias_vals)
such that I could then do
output = wrapped_runtime_mod(runtime_mod)(data_arr)