`transpose_3d` for `hls_stream` missing
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
- #1502 di @hadronic-arvind — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 28/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Ambito
- embedded-iot, machine-learning
Direzione di ricerca
The failing call is nnet::transpose_3d in firmware/nnet_utils/nnet_array.h (around lines 31-48), which takes plain arrays, while the io_stream build passes hls::stream objects. Start by checking how the Permute layer is emitted in the Vivado backend and whether a stream variant of the transpose exists. Done means the reproducer model in the issue compiles and hls_model.compile() runs. The linked pull request #1502 was closed without merging, so check why before starting.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I have the following model:
x_in = Input(shape=(1024,1,2))
x = Permute((3,1,2))(x_in)
x = Conv2D(8 , (7,1), padding='same', name='C1')(x)
x = ReLU(name='C1_relu')(x)
x = Conv2D(16, (7,1), padding='same', name='C2')(x)
x = ReLU(name='C2_relu')(x)
x = Conv2D(32, (7,1), padding='same', name='C3')(x)
x = ReLU(name='C3_relu')(x)
x = Conv2D(64, (7,1), padding='same', name='C4')(x)
x = ReLU(name='C4_relu')(x)
x = AveragePooling2D((1,256), (1,256), padding='same', name='AVG_pool_1')(x)
x = AveragePooling2D((1,4), (1,4), padding='same', name='AVG_pool_2')(x)
x = Flatten()(x)
x = Dense(256, name='D1')(x)
x = ReLU(name='D1_relu')(x)
x = Dense(22, name='D2')(x)
x_out = Softmax(name='D2_softmax')(x)
model = models.Model(x_in, x_out)
And I am trying to convert it to an hls_model, everything went alright until i hit an error which I think it is caused by the permute layer.
Here is the rest of the code to replicate the behavior:
LOSS = tf.keras.losses.CategoricalCrossentropy()
OPTIMIZER = tf.keras.optimizers.Adam(learning_rate=1E-3)
model.compile(loss=LOSS, optimizer=OPTIMIZER, metrics=["accuracy"])
import hls4ml
hls4ml.model.optimizer.get_optimizer('output_rounding_saturation_mode').configure(layers=['Activation'])
hls4ml.model.optimizer.get_optimizer('output_rounding_saturation_mode').configure(rounding_mode='AP_RND')
hls4ml.model.optimizer.get_optimizer('output_rounding_saturation_mode').configure(saturation_mode='AP_SAT')
hls_config = hls4ml.utils.config_from_keras_model(model, granularity='name')
Precision = 'ap_fixed<16,6>'
Reuse_Factor = 1
hls_config['Model']['Precision'] = Precision
hls_config['Model']['ReuseFactor'] = Reuse_Factor
for Layer in hls_config['LayerName'].keys():
hls_config['LayerName'][Layer]['Precision'] = Precision
hls_config['LayerName'][Layer]['Strategy'] = 'Latency'
hls_config['LayerName'][Layer]['ReuseFactor'] = Reuse_Factor
hls_config['LayerName']['D2_softmax']['Strategy'] = 'Stable'
cfg = hls4ml.converters.create_config(backend='Vivado')
cfg['IOType'] = 'io_stream' # Must set this if using CNNs!
cfg['HLSConfig'] = hls_config
cfg['KerasModel'] = model
cfg['OutputDir'] = 'model_16b_rf1/'
cfg['XilinxPart'] = 'xcvu9p-flga2104-2L-e'
hls_model = hls4ml.converters.keras_to_hls(cfg)
hls_model.compile()
and this is the error:
firmware/myproject.cpp: In function ‘void myproject(hls::stream<nnet::array<ap_fixed<16, 6>, 2> >&, hls::stream<nnet::array<ap_fixed<16, 6>, 22> >&)’:
firmware/myproject.cpp:61:52: error: cannot convert ‘hls::stream<nnet::array<ap_fixed<16, 6>, 2> >’ to ‘nnet::array<ap_fixed<16, 6>, 2>*’
61 | nnet::transpose_3d<input_t, layer2_t, config2>(input_1, layer2_out); // permute
| ^~~~~~~
| |
| hls::stream<nnet::array<ap_fixed<16, 6>, 2> >
In file included from firmware/parameters.h:12,
from firmware/myproject.cpp:22:
firmware/nnet_utils/nnet_array.h:31:12: note: initializing argument 1 of ‘void nnet::transpose_3d(data_T*, res_T*) [with data_T = nnet::array<ap_fixed<16, 6>, 2>; res_T = nnet::array<ap_fixed<16, 6>, 1>; CONFIG_T = config2]’
31 | data_T data[CONFIG_T::depth * CONFIG_T::height * CONFIG_T::width],
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
firmware/nnet_utils/nnet_array.h: In instantiation of ‘void nnet::transpose_3d(data_T*, res_T*) [with data_T = nnet::array<ap_fixed<16, 6>, 2>; res_T = nnet::array<ap_fixed<16, 6>, 1>; CONFIG_T = config2]’:
firmware/myproject.cpp:61:71: required from here
firmware/nnet_utils/nnet_array.h:48:92: error: no match for ‘operator=’ (operand types are ‘nnet::array<ap_fixed<16, 6>, 1>’ and ‘nnet::array<ap_fixed<16, 6>, 2>’)
48 | data_t[idx_t[0] * dims_t[1] * dims_t[2] + idx_t[1] * dims_t[2] + idx_t[2]] = data[idx[0] * dims[1] * dims[2] + idx[1] * dims[2] + idx[2]];
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from firmware/defines.h:6,
from firmware/myproject.h:27,
from firmware/myproject.cpp:21:
firmware/nnet_utils/nnet_types.h:26:12: note: candidate: ‘nnet::array<T, N>& nnet::array<T, N>::operator=(const nnet::array<T, N>&) [with T = ap_fixed<16, 6>; unsigned int N = 1]’
26 | array& operator=(const array &other) {
| ^~~~~~~~
firmware/nnet_utils/nnet_types.h:26:35: note: no known conversion for argument 1 from ‘nnet::array<ap_fixed<16, 6>, 2>’ to ‘const nnet::array<ap_fixed<16, 6>, 1>&’
26 | array& operator=(const array &other) {
| ~~~~~~~~~~~~~^~~~~
g++: error: myproject.o: No such file or directory
I thought that the Permute layer is already supported by hls4ml, or I am wrong?? How can I fix such an error?
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 605
- Merge medio
- 6g 16h
- PR unite (30g)
- 20
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fastmachinelearning/hls4ml
-
vitis:fifo_depth_optimization fails for models with more than one input or outputForse già presa @dgaytanv l’ha presa 2 giorni fa. Apertabug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
fastmachinelearning/hls4ml#1582 ·
I maintainer di solito rispondono entro 3 giorni
-
bug Stale
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
fastmachinelearning/hls4ml#771 · 1 commento ·
I maintainer di solito rispondono entro 3 giorni
-
error while converting onnx model to hlsForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug Stale
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fastmachinelearning/hls4ml#686 · 2 commenti ·
I maintainer di solito rispondono entro 3 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
fastmachinelearning/hls4ml#630 ·
I maintainer di solito rispondono entro 3 giorni
-
Stale
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100
fastmachinelearning/hls4ml#297 · 4 commenti ·
I maintainer di solito rispondono entro 3 giorni
Tutte le issue di fastmachinelearning/hls4ml
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
lidofinance/diffyscan#239 ·
I maintainer di solito rispondono entro 1 giorno
-
docs: the dev-setup table and AGENTS.md name the reviewed_by guard that CI's Changelog job runsApertaarea: tools documentation good first issue ready for a contributor
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
eyalgolan/statecraft-israel#873 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
GET rooms API returns 500 due to nonexistent Room.is_active attributeForse già presa @Mars-60 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
Add cover art to song rowsApertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 5 giorni
-
Harmony OPeNDAP SubSetter (HOSS) Geographic production rssmif16d 7 XYZ_PROV
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
nasa/harmony-autotester#341 ·