The TVM documents show examples of how to deploy a Relay IR Module in C++ by exporting a .so library and loading it in C++. https://tvm.apache.org/docs/how_to/deploy/cpp_deploy.html
Is there a similar example for using Relax module?
Using relax.build() and exporting that library doesnt seem to work. In C++ I am not able to get my main function.
My input Relax:
# from tvm.script import ir as I
# from tvm.script import relax as R
@I.ir_module
class Module:
@R.function(private=False)
def main(x: R.Tensor((2,), dtype="float32")) -> R.Tensor((2,), dtype="float32"):
a1: R.Tensor((2,), dtype="float32") = R.multiply(x, R.const(1.0, "float32"))
b1: R.Tensor((2,), dtype="float32") = R.add(a1, R.const(0.0, "float32"))
c1: R.Tensor((2,), dtype="float32") = R.multiply(b1, R.const(1.0, "float32"))
d1: R.Tensor((2,), dtype="float32") = R.add(c1, c1)
y: R.Tensor((2,), dtype="float32") = R.nn.relu(d1)
return y
seq = tvm.transform.Sequential(
[
relax.transform.Normalize(),
relax.transform.EliminateCommonSubexpr(),
relax.transform.FoldConstant(),
relax.transform.CanonicalizeBindings(),
relax.transform.LegalizeOps(),
]
)
finalMod = seq(mod)
target = tvm.target.Target("c", host="c")
exe = relax.build(finalMod, target)
exe.export_library("myLib.so")
when I load the .so in C++ I cant find the “main” function thats defined in my IRModule