Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"warning: integer constant is so large that it is unsigned" causes hls_model.compile() to fail #1011

Open
3 of 4 tasks
RikPi opened this issue May 13, 2024 · 0 comments
Open
3 of 4 tasks
Labels

Comments

@RikPi
Copy link

RikPi commented May 13, 2024

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. Tested on pip releases 0.8.0 and 0.8.1
  • 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

Since I added a LSTM/GRU layer after my CNN, it won't compile, reporting multiple overflow errors.
I am running hls4ml 0.8.1 on a Ubuntu 22.04 (with CUDA) Docker, Vivado is 2019.1. I have deleted Vivado's own ld executable and linked the system one to make it work with Ubuntu 22.04. The compilation works when I have just a CNN.

The first warning messages I get are:

In file included from firmware/myproject.cpp:4:
firmware/parameters.h:96:764: warning: integer constant is so large that it is unsigned
   96 | const ap_uint<config2::filt_height * config2::filt_width> config2::pixels[] = [OMITTED]

And the error log terminates with:

/usr/bin/ld: cannot find myproject.o: No such file or directory
collect2: error: ld returned 1 exit status

A full log is available as attachment below.

Please let me know if I can provide more useful context and thank you, keep up the good work!

Details

Steps to Reproduce

This is my config code:

import hls4ml
import plotting

# Import model
hls_config = hls4ml.utils.config_from_keras_model(model_loaded, granularity='name')

# Set model config
hls_config['Model']['Precision'] = 'ap_fixed<24,6>'
hls_config['Model']['ReuseFactor'] = 1
hls_config['Model']['Strategy'] = 'Latency'

# Set layer config
for Layer in hls_config['LayerName'].keys():
    hls_config['LayerName'][Layer]['Strategy'] = 'Latency'
    hls_config['LayerName'][Layer]['ReuseFactor'] = 1
    hls_config['LayerName'][Layer]['Precision'] = 'ap_fixed<24,6>'

# Last layer stable
hls_config['LayerName']['output_dense']['Strategy'] = 'Stable'
plotting.print_dict(hls_config)

# Generate config for Vivado
cfg = hls4ml.converters.create_config(backend='VivadoAccelerator', part= 'XCZU7EV-FFVC1156-2-E')
cfg['IOType'] = 'io_stream'
cfg['HLSConfig'] = hls_config
cfg['KerasModel'] = model_loaded
cfg['OutputDir'] = 'COSMIC_CRNN_LSTM_98/'
cfg['Board'] = 'zcu106'
cfg['Part'] = 'XCZU7EV-FFVC1156-2-E'
cfg['XilinxPart'] = 'XCZU7EV-FFVC1156-2-E'
cfg['Interface'] = 'axi_stream'
cfg['InputData'] = 'X_test.npy'
cfg['OutputPredictions'] = 'Y_test.npy'

hls_model = hls4ml.converters.keras_to_hls(cfg)
hls_model.compile()

After I run it, I get the following error:
hls4ml_error.txt

Expected behavior

The model should compile.

Actual behavior

The model does not compile.

Optional

Possible fix

I am not very familiar with C++ or the inner workings of Tensorflow/hls4ml but there could be something wrong in the way the LSTM/GRU layer is generated in HLS.

Additional context

@RikPi RikPi added the bug label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant