@HDCharles
Thanks for the help. It works now!
The reason I create such test script is to duplicate the same “QuantizedCPU” backend error I encountered when I saved the trace_model into a file, says, “trace_model.pt” and then tried to load it by using
rknn.load_pytorch(model="trace_model.pt", input_size_list=input_size_list)

where rknn is a toolkit for RockChip NPU.
Now my question is: is there a way to save the trace_model with torch.no_grad() ? such that when rknn.load_pytorch would not encounter “QuantizedCPU” backend error?
or has to modify rknn.load_pytorch module to add
with torch.no_grad():
in it before parsing the model script?
Thank you again for your help.