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

TF model implementation in tf version 2.18.0 #1150

Open
4 tasks
ixiotidi opened this issue Dec 13, 2024 · 1 comment
Open
4 tasks

TF model implementation in tf version 2.18.0 #1150

ixiotidi opened this issue Dec 13, 2024 · 1 comment
Labels

Comments

@ixiotidi
Copy link

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

I'm trying to compile a tensorflow 2.18 model that I created using the Function-API with HLS4ML and I"m getting the following error:

hlsConfig = comp.utils.config_from_keras_model(model, granularity='model')

File "/workspace/Conda/envs/myenv/lib/python3.9/site-packages/hls4ml/utils/config.py", line 159, in config_from_keras_model
layer_list, _, _, _ = hls4ml.converters.parse_keras_model(model_arch, reader)
File "/workspace/Conda/envs/myenv/lib/python3.9/site-packages/hls4ml/converters/keras_to_hls.py", line 260, in parse_keras_model
input_shapes = [output_shapes[inbound_node[0]] for inbound_node in keras_layer['inbound_nodes'][0]]
IndexError: list index out of range

Details

When I convert my model into the json format with the to_json() method of tf. I can see that the inbound_node entry in my input_layer is empty and I believe this is causing the issue. If I try to compile my model with Sequential then it's looking for the batch_input_shape() which again doesn't exist in later versions of tf.

Steps to Reproduce

Take the CNN example from the HLS4ML tutorial with the update TF version and the error is already there.

  1. pip install hls4ml (version 0.8.1)

Expected behavior

I would have expected the same behaviour as I see with tf version 2.1.0 which is what is coded in the keras_parser()

Actual behavior

I get the error seeing above

Optional

Possible fix

Compare model json format against tf version dependent template in order to extract the correct names rather than using hard-coded dictionary entries?

Additional context

Add any other context about the problem here.

@ixiotidi ixiotidi added the bug label Dec 13, 2024
@JanFSchulte
Copy link
Contributor

Hi! Thanks for getting in touch. First of all, we just released version 1.0.0 of hls4ml and generally recommend switching to it. In your case, unfortunately this would not help as we currently do not support tensorflow versions above 2.14.1 even in the new release, see https://github.com/fastmachinelearning/hls4ml/blob/main/setup.cfg#L33.

We are aware of this limitation and will work to improve this for future releases, but at the moment exactly these kind of changes in TF make it difficult to support a wide range of versions.

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

2 participants