- 
                Notifications
    
You must be signed in to change notification settings  - Fork 484
 
Description
Prerequisites
Please make sure to check off these prerequisites before submitting a bug report.
- Test that the bug appears on the current version of the master branch. Make sure to include the commit hash of the commit you checked out.
 - Check that the issue hasn't already been reported, by checking the currently open issues.
 - If there are steps to reproduce the problem, make sure to write them down below.
 - If relevant, please include the hls4ml project files, which were created directly before and/or after the bug.
 
Quick summary
Pytorch + VivadoAccelerator fails to compile
Details
Trying to compile a Pytorch model with 4 CNN layers and one Dense layer fails with VivadoAccelerator, 'io_parallel' and stratergy Resource for layers with more than 4096 parameters.
Steps to Reproduce
- Clone the hls4ml repository
 - Checkout the master branch, with commit hash: [8a4f2685]
 - I can't share the model architecture, but this is the HLS4ML configuration I'm using to convert it.
The size of each layer is: 
Number of Parameters:
conv1.weight                                     48
conv1.bias                                          16
conv2.weight                                    1536
conv2.bias                                           32
conv3.weight                                     6144
conv3.bias                                            64
conv4.weight                                    24576
conv4.bias                                            128
dense1_finetuned.weight                 523776
dense1_finetuned.bias                        2
`
config = hls4ml.utils.config_from_pytorch_model(model, input_shape=[(1, 1, 16384)], granularity='name', backend='VivadoAccelerator', transpose_outputs = True)
config['Model']['Precision'] = 'ap_fixed<16,6>'
config['Model']['ReuseFactor'] = 1
for Layer in config['LayerName'].keys():
config['LayerName'][Layer]['Strategy'] = 'Latency'
config['LayerName'][Layer]['ReuseFactor'] = 6000
for layer_name, param in model.named_parameters():
if param.requires_grad:
num_params = param.numel()
if num_params > 4096:
name = layer_name.split('.')[0]
print("Layer {} is too large ({}), are you sure you want to train?".format(name, num_params))
config['LayerName'][name]['Strategy'] = 'Resource'
config['LayerName'][name]['ReuseFactor'] = 7936
board = 'zcu102'
backend = 'VivadoAccelerator'
OutputDir = ' my-hls-test-quantized-torch'
io_type = 'io_pararell'
hls_model = hls4ml.converters.convert_from_pytorch_model(
model, hls_config=config,
output_dir=f'{OutputDir}/model_v1',
backend=backend,
board=board
)
hls_model.compile()
`
Expected behavior
No errors in the model compilation.
Actual behavior
Error:
-> hls_model.compile() (Pdb) WARNING: You set a Part that does not correspond to the Board you specified. The correct Part is now set. OSError: my-hls-test-quantized-torch/model_v1/firmware/myproject-870a07f4.so: cannot open shared object file: No such file or directory
Additional context
My PC has a 16GB RAM and I added 32GB of SWAP.
I'm not sure if this is a memory problem.
Thanks in advance for any idea or recommendation.