I’ve put up an initial PR here: https://github.com/apache/incubator-tvm/pull/6522.
An issue has come up, what do we name the python module?
Option 1
We name the module tvm.tvmscript.
Example usage:
import tvm
# Can still use this though
@tvm.script # or tvm.script.tir
def my_func():
pass
@tvm.script # or tvm.script.module
class Mod:
def my_func():
pass
string = my_func.asscript()
assert(string == tvm.tvmscript.parse(string))
# can also do
from tvm import tvmscript
assert(string == tvmscript.parse(string))
The disadvantage here is that tvm.tvmscript repeats tvm twice. But it does make it explicit that the script we are using is tvm script (as opposed to hybrid script).
Option 2
We name the module tvm.script. We still refer to this as “TVM Script” in all documentation, etc.
import tvm
# Can't use tvm.script as it is a namespace
@tvm.script.tvm # or tvm.script.tir (see option 2a)
def my_func():
pass
@tvm.script.tvm # or tvm.script.module
class Mod:
def my_func():
pass
string = my_func.asscript()
assert(string == tvm.script.parse(string))
# can also do
from tvm import script
assert(string == script.parse(string))
If we use tvm.script as the module name we cannot use the @tvm.script decorator. We have two options for the decorator. Option 2a: use @tvm.script.tvm. Option 2b: use @tvm.script.tir for functions and @tvm.script.module for modules.
The disadvantage here is that the name script can be confusing when used unqualified (when using from imports). Pytorch uses this approach, but they only have a single script in their package.
Let me know which you like best. (Hopefully this isn’t too much bike shedding).