Why are the output parameters of tvm.relay.optimize empty?

I am a beginner in using TVM. I have traced the resnet50. Now, I want to get the optimized modules using: model = ResNet50(10, 3) model.to(dtype)

    trace_input = torch.rand(1, 3, 224, 224)
    traced_model = torch.jit.trace(model, trace_input)
    for p in traced_model.parameters():
        p.requires_grad_(False)
    
    shape_list = [(i.debugName().split('.')[0], i.type().sizes()) 
        for i in  list(traced_model.graph.inputs())[1:]]
    mod, mod_params = tvm.relay.frontend.from_pytorch(traced_model, shape_list, default_dtype=dtype_str)
    mod_optimized, mod_params_optimized = tvm.relay.optimize(mod, target, params=mod_params)

However, the length of the mode_params_optimized dictionary is zero. I would appreciate it if anyone could suggest to me how to find the problem.

This is expected, during optimize parameters are bound to the module as constants. If you print mod_optimized you will see a lot of constants embedded directly in the module.

1 Like