Package: pybondmachine
pybondmachinepybondmachine is the Python library designed to streamline the development of FPGA accelerators through the use of the BondMachine framework.With this library you can:(phase 1) Build a firmware starting from python code. You can use the BondMachine framework to create a neural network accelerator, or you can use the library to create a custom accelerator.(phase 2) Interact with the firmware to perform low-latency inference or to use the custom accelerator.Phase 1PrerequisitesPython 3.6 or higherpipVivado 2019.1 or higher (if you want to build the firmware)Tensorflow (to train or load a model)BondMachine framework (download it fromhere)Installpip3 install pybondmachineUsageimportsfrom pybondmachine.prjmanager.prjhandler import BMProjectHandler
from pybondmachine.converters.tensorflow2bm import mlp_tf2bmLoad your neural network model (or train it from scratch)import tensorflow as tf
model = tf.keras.models.load_model(os.getcwd()+"/tests/model.h5")Convert your neural network model for BondMachineoutput_file = "modelBM.json"
output_path = os.getcwd()+"/tests/"

# dump the json input file for neuralbond, the BM module that will be used to build the firmware
mlp_tf2bm(model, output_file=output_file, output_path=output_path)Create and initialize a BM project with the params you preferprjHandler = BMProjectHandler("sample_project", "neuralnetwork", "projects_tests")

prjHandler.check_dependencies()
prjHandler.create_project()

config = {
    "data_type": "float16",
    "register_size": "16",
    "source_neuralbond": output_path+output_file,
    "flavor": "axist",
    "board": "zedboard"
}

prjHandler.setup_project(config)Build the firmwareprjHandler.build_firmware()Phase 2PrerequisitesPython 3.6 or higherpipPynq (if you want to use the custom accelerator)FPGA deviceLoad the predictorfrom pybondmachine.overlay.predictor import PredictorSet the model specsmodel_specs = {
    "data_type": "fps16f6",
    "register_size": 16,
    "batch_size": 128,
    "flavor": "axist",
    "n_input": 4,
    "n_output": 2,
    "benchcore": True,
    "board": "zedboard"
}Specify firmware name and firmware pathfirmware_name = "firmware.bit"
firmware_path = "proj_zedboard_axist_fp16_6_expanded_01/"Initialize the predictorpredictor = Predictor("firmware.bit", firmware_path, model_specs)Load the data to be processedpredictor.load_data("proj_zedboard_axist_fp16_6_expanded_01/banknote-authentication_X_test.npy", 
                    "proj_zedboard_axist_fp16_6_expanded_01/banknote-authentication_y_test.npy")Load the overlay i.e. program the FPGARemember that it is necessary that you call predictor.load_data before loading the overlaypredictor.load_overlay()Perform inferencestatus, predictions = predictor.predict()Phase 1 details under the hoodThis python package is basically a wrapper of the BondMachine helper tool. It allows you to create a project, to build the firmware and to convert a neural network model to a json file that can be used as input for the BondMachine framework. Or, if you prefer, you can use the library to create a custom accelerator.
Under the hood,bmhelpercreate the project, modify all the parameters of the configuration files inside the project and it checks the dependencies.
Indeed, you can use bmhelper from CLI if you have installed it.
So, to use the python library bmhelper is necessary and you can get it from here:bmhelperunder the section "Installation".