@tqchen @manupa-arm @mjs @giuseros great discussions so far!
Identifiers that begin with underscore are reserved by the C standard. Conformant C code should not use them, dropping the _ and using just “tvm_…” would be conformant.
I agree with this. Do we need to consider distinguishing this prefix from that used within TVM itself? e.g. tvmgen_
so that stacktraces when compute is launched from the shared library are clear.
I dont follow why a “prefix” necessarily mean user being able to select it? If “prefix” is not the right term we should not call it a prefix.
Yeah this is just me stating that we were proposing tvm_<model_name>_<function_name>
, where <model_name>
is termed a prefix. I’d call tvm_<model_name>_
a prefix here.
I agree that having a common prefix is helpful in the dso landscape to clearly identify function generated by tvm. To faciliate discussion, consider the following code
m = tvm.runtime.load_module("x.so") # Option P0: require explicit query using tvm_run run = m["tvm_run"] # Option P1: the underlying symbol is "tvm_run" run = m["run"]
I believe we are still talking about P0 atm for simplicity(direct correspondence of symbol and packed func name), but allow the AOT generator to append a prefix(like @areusch 's comment of prefix starting from char 0). My main comment of backward compact is when we start to choose P1. If we go with P1, then we will need to put more thoughts into it.
@tqchen, in this case, the main function being queried should be the factory function for Module-based Model Runtime Interface, no? In that case, it seems reasonable to require:
m = tvm.runtime.load_module("x.so")
# User looks up module via prefix
executor = m["customprefix_tvm_modelname"]()
# Or perhaps TVM can fall back to the standard one
executor = m["modelname"](). # Looks up tvmgen_modelname
executor["set_input"]("foo", bar)
# ...
It should be possible to include the prefix when looking up the module-specific functions. It’s also worth pointing out here that this discussion is for the case of loading a module using the C++ runtime. With the C runtime, I think it’s expected that the user chooses <prefix>
to match their firmware implementation.