External weights vivado accelerator
Created by: GiuseppeDiGuglielmo
Extend the VivadoAccelerator
backend and add programmable weights. An ideal setup is a Xilinx Zynq/ZynqMP board (ARM core + programmable logic).
The backend generates code for Vivado HLS, Vivado, and Vivado SDK:
- the hls4ml IP with AXI master interfaces to move input features, output predictions, and weights between off-chip RAM and FPGA chip
- a complete Vivado project that integrates the hls4ml IP (for the target board/chip)
- a complete baremetal application to control and program the accelerator
Type of change
Some changes to the signature of the function convert_from_keras_model()
:
hls_model = hls4ml.converters.convert_from_keras_model(
model=model,
clock_period=CLOCK_PERIOD,
backend='VivadoAccelerator',
board=BOARD_NAME,
part=FPGA_PART,
io_type='io_stream',
interface='axi_master',
driver='c',
input_data_tb=DATA_DIR+'/X_test.npy',
output_data_tb=DATA_DIR+'/y_test.npy',
hls_config=config,
output_dir=OUTPUT_DIR)
and a new function write_header_file()
to write a header file with an harcoded dataset:
hls4ml.writer.vivado_accelerator_writer.VivadoAcceleratorWriter.write_header_file(hls_model, X_test, y_test, y_qkeras, y_hls, 64, OUTPUT_DIR + '/sdk/common/data.h')
Tests
You can test it with the example at this repo: https://github.com/GiuseppeDiGuglielmo/test-hls4ml-backend
Right now, we support Ultra96v2, but more Zynq/ZynqMP boards can be added.