Hey I just try to lower resnet18 of mxnet to target=“c”, I got the c code now, but it can not run on gcc, because it does not have the funciton “main”. I got plenty of computational functions in the c code, but there is not a function “main” to call them. I am wondering how to generate the backend code with function “main” to call these functions. here is the code
pack_dict = {
"resnet18_v1": ["nn.max_pool2d", "nn.global_avg_pool2d"],
"resnet34_v1": ["nn.max_pool2d", "nn.global_avg_pool2d"],
"resnet18_v2": ["nn.max_pool2d", "nn.global_avg_pool2d"],
"resnet34_v2": ["nn.max_pool2d", "nn.global_avg_pool2d"],
"resnet50_v2": ["nn.max_pool2d", "nn.global_avg_pool2d"],
"resnet101_v2": ["nn.max_pool2d", "nn.global_avg_pool2d"],
}
model = "resnet18_v1"
assert model in pack_dict
dtype_dict = {"data": "float32"}
shape_dict = {"data": (1, 3, 224, 224)}
gluon_model = vision.get_model(model, pretrained=True)
mod, params = relay.frontend.from_mxnet(gluon_model, shape_dict)
# # Update shape and type dictionary
shape_dict.update({k: v.shape for k, v in params.items()})
dtype_dict.update({k: str(v.dtype) for k, v in params.items()})
library = relay.build(mod, target="c", params=params)
And the c code generated looks like this:
I don’t know how to run these c code, is there a way to generate c code with function main? By the way how to set input data when I need to run c code like this? Thank you!