Description
profiling.numerical() fails when used with a multi-input hls4ml model. The same model can successfully run inference using hls_model.predict(), so the issue appears to be isolated to the profiling code.
Environment
- hls4ml branch:
main
- hls4ml commit:
717a57a309ab85c855ae2985d821d6a643cb7bc6
- Multi-input Keras model converted with hls4ml
Working inference
The model accepts four inputs, which are passed as a list of NumPy arrays:
model_dict = {k: np.ascontiguousarray(v, dtype=np.float64)
for k, v in model_dict.items()}
hls_inputs = []
for var in model.hls_jet_model.get_input_variables():
hls_inputs.append(
np.ascontiguousarray(model_dict[var.name], dtype=np.float64)
)
with shapes:
basic_input (4722, 16, 21)
constituent_fraction (4722, 16)
jet_features (4722, 2)
pt_mask (4722, 16)
Inference works correctly:
model.hls_jet_model.predict(hls_inputs)
Profiling failure
Calling:
wp, wph, ap, aph = profiling.numerical(
model=model.jet_model,
hls_model=model.hls_jet_model,
X=hls_inputs,
)
raises:
Traceback (most recent call last):
...
File ".../profiling.py", line 546, in numerical
data = activations_hlsmodel(hls_model, X, fmt='summary', plot=plot)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../profiling.py", line 330, in activations_hlsmodel
_, trace = model.trace(np.ascontiguousarray(X))
^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (4, 4722) + inhomogeneous part.
Description
profiling.numerical()fails when used with a multi-input hls4ml model. The same model can successfully run inference usinghls_model.predict(), so the issue appears to be isolated to the profiling code.Environment
main717a57a309ab85c855ae2985d821d6a643cb7bc6Working inference
The model accepts four inputs, which are passed as a list of NumPy arrays:
with shapes:
Inference works correctly:
Profiling failure
Calling:
raises: