hls4ml
hls4ml copied to clipboard
Compile Problem: Pytorch to hls convertion
Hi, thanks for your great open-source works for FPGA. But currency I encounter some difficulties with your reference work. Here is few problems:
- When I converter your three-layer of provided PyTorch model, it failed shows like that. My python is 3.8 and Pytorch version is 1.10.0+cu113. hls4ml is 0.6.0.
Loading configuration from pytorch-config.yml
Interpreting Model ...
/home/jjcc/.local/lib/python3.8/site-packages/torch/serialization.py:671: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/jjcc/.local/lib/python3.8/site-packages/torch/serialization.py:671: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/jjcc/.local/lib/python3.8/site-packages/torch/serialization.py:671: SourceChangeWarning: source code of class 'torch.nn.modules.activation.ReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
/home/jjcc/.local/lib/python3.8/site-packages/torch/serialization.py:671: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Softmax' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File "/home/jjcc/.local/bin/hls4ml", line 277, in <module>
main()
File "/home/jjcc/.local/bin/hls4ml", line 62, in main
args.func(args, extra_args)
File "/home/jjcc/.local/bin/hls4ml", line 133, in _convert
model = hls4ml.converters.convert_from_config(args.config)
File "/home/jjcc/.local/lib/python3.8/site-packages/hls4ml/converters/__init__.py", line 122, in convert_from_config
model = pytorch_to_hls(yamlConfig)
File "/home/jjcc/.local/lib/python3.8/site-packages/hls4ml/converters/pytorch_to_hls.py", line 128, in pytorch_to_hls
reader = PyTorchFileReader(config) if isinstance(config['PytorchModel'],str) else PyTorchModelReader(config)
File "/home/jjcc/.local/lib/python3.8/site-packages/hls4ml/converters/pytorch_to_hls.py", line 77, in __init__
raise Exception('Must specify input shape ("InputShape") in config!')
Exception: Must specify input shape ("InputShape") in config!
- I just want to compile your PW+DW+PW kernels, and if you have other good advice to convert it into your HLS codes.
Thanks much for your help.
Brs, Thomas