Hi everyone,
I am trying to call a module (created from relay “conv2d”) in C++. Following the example in:
https://docs.tvm.ai/deploy/cpp_deploy.html
I have exported the library as:
graph, lib, params = relay.build_module.build(mod, params = dict_params, target=target)
lib.export_library("conv2d_cpu_opt.so")
and when I do print(mod)
I get the following
def @main(%data: Tensor[(1, 3, 227, 227), float32], %kernel: Tensor[(96, 3, 11, 11), float32]) -> Tensor[(1, 96, 55, 55), float32] {
nn.conv2d(%data, %kernel, strides=[4, 4], padding=[0, 0, 0, 0], channels=96, kernel_size=[11, 11], out_dtype="float32") /* ty=Tensor[(1, 96, 55, 55), float32] */
}
I am looking for the function signature, since I need it to pass the right arguments in C++.
From the print(mod)
my guess is that the function name is “main”, and that the function signature would be something like my_func(data,kernel,output)
or maybe even output = my_func(data,kernel)
.
However, when I do:
f = mod.GetFunction(“main”)
CHECK(f != nullptr);
in the C++ program, I get
terminate called after throwing an instance of 'dmlc::Error'
what(): [11:38:05] conv2d_deploy_cpu.cc:43: Check failed: f != nullptr:
That is, mod.GetFunction
is not able to retrieve any function with name “main”.
Does anybody know what I am missing and how I can get the signature and function name from a module built out of a relay function?
I really appreciate any help you can provide on this issue. I am tagging @masahi in this post since this seems to be related to