Skip to content

Multiple stream clones with different numbers of outputs crash Keras converter. #905

Closed
@calad0i

Description

@calad0i

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

Keras converter crashes when multiple clone operations are required with different precision. PR comes later.

Steps to Reproduce

(Sort of) minimal reproduce example:

from keras.layers import Dense, Add

inp = keras.Input(shape=(10,))
x = Dense(10)(inp)
y = Dense(10)(inp)
z = Dense(10)(inp)
xy = Add()([x,y]) # 5
xy = Add()([xy,y]) # 5
model = keras.Model(inp, [xy, z])

model_hls = convert_from_keras_model(model, io_type='io_stream', output_dir='/tmp/stream_clone_crash', hls_config = {'Model':{'Precision':'fixed<32,10>', 'ReuseFactor':1}})

Cause:
optimization at https://github.com/fastmachinelearning/hls4ml/blob/0d48affe108f9df470950fe08a73bc3b5c3f2338/hls4ml/backends/fpga/passes/clone.py#L30C15-L30C15: When two clone happens with different #outputs, the template generated last time will crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions