facebookresearch / dlrm

An implementation of a deep learning recommendation model (DLRM)
MIT License
3.71k stars 825 forks source link

ONNX export from pretrained pt file #350

Closed NiranjanRavi1993 closed 1 year ago

NiranjanRavi1993 commented 1 year ago

Hi all, Thank you for the repository and detailed explanation. I am trying to export the pretrained model file "https://dlrm.s3-us-west-1.amazonaws.com/models/tb0875_10M.pt" to ONNX format. My aim is to identify what are the operators in the model.

  1. Initially, I loaded the pt model in Netron. Since model was too big, Netron wasn't able to load the model.

  2. I tried using the torch function torch.onnx.export("modelfile.pt", dummy_inputs, "save_model.onnx"). When I try this approach, I get an Attribute error: 'dict' has no attribute "modules". I have used the torch.onnx.export for CNN architectures and they work perfectly fine. I guess the 'dummy_inputs' which I am feeding to the models is not right. Is there any way I can modify this approach/would be helpful to know if there is any sample inputs which would works.

  3. I used the dlrm_s_pytorch. py (https://github.com/facebookresearch/dlrm/blob/main/dlrm_s_pytorch.py) to load the model and export to ONNX. But I faced state_dict load error and tensor mismatch error.

It would be helpful to know if its possible to export the pretrained model without training/fine-tuning the network.

Thank you.

hrwleo commented 1 year ago

已收到邮件  阿里阿豆故咋一马斯!如未及时回复,请致电15868848097  QQ:812737452