Hello, after converting GRU network to IP core using hls4ml, the output of IP core is not always 0. Here is my conversion code.
I maintainer di solito rispondono entro 3 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 18/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Ambito
- machine-learning
Direzione di ricerca
The reproduction is the test_gru function in the posted script, which converts a single-layer nn.GRU with hls4ml using the Vivado backend and io_stream, then compares the HLS prediction to PyTorch with np.testing.assert_allclose at atol 0.1. Start by running that script with a fixed random seed to see whether the mismatch reproduces and how large it is, and check the precision setting ap_fixed<16,6> against the hidden-state range. The issue does not say what the expected output is, so confirm the intended behaviour with the maintainers before changing anything.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
from pathlib import Path
import numpy as np
import pytest
import torch
import torch.nn as nn
from hls4ml.converters import convert_from_pytorch_model
from hls4ml.utils.config import config_from_pytorch_model
from hls4ml.utils import plot_model
import plotting
import hls4ml
test_root_path = Path(file).parent
import os
os.environ['PATH'] = '/tools/Xilinx/Vivado/2019.2/bin:' + os.environ['PATH']
class GRUNet(nn.Module):
def init(self):
super().init()
self.rnn = nn.GRU(4, 2, num_layers=1, batch_first=True, bias=True)
def forward(self, x, h0):
output, hnn = self.rnn(x, h0)
return output
def test_gru(backend, io_type):
model = GRUNet()
model.eval()
X_input = torch.randn(1, 1, 4)
h0 = torch.zeros(1, 1, 2)
pytorch_prediction = model(torch.Tensor(X_input), torch.Tensor(h0)).detach().numpy()
config = config_from_pytorch_model(
model, [(None, 1, 4), (None, 1, 2)], channels_last_conversion="off", transpose_outputs=False
)
config['Model']['ReuseFactor'] = 1
config['Model']['Precision'] = 'ap_fixed<16,6>'
print("-----------------------------------")
print("Configuration")
plotting.print_dict(config)
print("-----------------------------------")
output_dir = str(test_root_path / f'hls4mlprj_pytorch_api_gru_{backend}_{io_type}')
#hls_model = convert_from_pytorch_model(model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type, part='xcu250-figd2104-2L-e')
hls_model = convert_from_pytorch_model(model, hls_config=config, output_dir=output_dir, backend=backend, io_type=io_type,
part='xc7z045ffg900-2',clock_period = 4)
plot_model(hls_model, show_shapes=True, show_precision=True, to_file=None)
hls_model.compile()
hls_prediction = np.reshape(hls_model.predict([X_input.detach().numpy(), h0.detach().numpy()]), (1, 1, 2))
print("*****************************************")
print(X_input,h0,pytorch_prediction,hls_prediction)
print("*****************************************")
np.testing.assert_allclose(hls_prediction, pytorch_prediction, rtol=0, atol=1e-1)
hls_model.build(csim=True, export=True)
hls4ml.report.read_vivado_report(output_dir)
if name == 'main':
test_gru('Vivado', 'io_stream')
- Lingua principale
- Python
- Stelle
- 2.2k
- Fork
- 605
- Merge medio
- 7g 35m
- PR unite (30g)
- 19
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 1 giorno 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 75/100
common-workflow-language/cwl-utils#477 ·
I maintainer di solito rispondono entro 1 giorno
-
Add dependabotApertafeat
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 72/100
open-nudge/opentemplate#204 ·
I maintainer di solito rispondono entro 1 giorno
-
github-stale-ci-pr-closer: KV state is double-wrapped, never persists, and hits the depth-32 limitForse già presa @VascoSch92 l’ha presa oggi. Apertapriority:medium ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
OpenHands/extensions#781 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
curriculum documentation quality
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
githubnext/gh-aw-workshop#4638 ·
I maintainer di solito rispondono entro 1 giorno