Skip to content

franout/Cogitantium

Repository files navigation

Cogitantium

This is a discontinued project (master thesis).

Feel free to contact me if you wanna know more.

Hardware accelerator for Machine Learning on TUL PYNQ™-Z2 board, based on Xilinx Zynq SoC

Erasmus Master Thesis @Chalmers University of Technology and Polythecnic of Turin

Table of Contents

Clone

Clone this repo to your local machine using and feel free to contribute!

$ git clone https://github.com/franout/Cogitantium.git

Installation

For using the accelerator you only need to install tensorflow wheel and python according to Tensorflow for Pynq-Z2

The following command are used for loading and using the accelerator into the Tensorflow Lite environment:

DTPU_lib=tflite.load_delegate("./DTPU_delegate.so",options=[])
interpreter = tflite.Interpreter(model_path=tflite_model_file,experimental_delegates=[DTPU_lib])

The shared library is created with the following command :

$ python3.5 ./dtpu/software/create_library.py

Note: in the same folder there must be present the DTPU_delegate.cpp and DTPU_delegate.py used for building the library.

Setup

For editing, simulating and synthesizing the verilog code you can use whatever IDE and tools you prefer. In this project Xilinx Vivado Tools have been used

Features

The hardware accelerator is capable of tensor convolution, generally speaking matrix multiplication and accumulation.

Architecture

  • General architecture

    • Logical view

    image

    • Real Implementation

    image

    • Datapath of dtpu core

    image

  • Customizable hardware parameters (pre-synthesis)

    • ROWS, rows in the matrix multiplication unit (MXU)
    • COLUMNS, columns in the matrix multiplication unit (MXU)
    • SIZE WMEMORY, size of weight memory
    • ADDRESS SIZE WMEMORY
    • ADDRESS SIZE CSR
    • SIZE CSR, size of control and status register memor
    • DATA WIDTH CSR
    • DATA WIDTH WMEMORY
    • DATA WIDTH FIFO IN
    • DATA DIDTH FIFO OUT
    • MAX BOARD DSP, max dsp entities on the board

Software

For creating models:

  $ python3.5 ./dtpu/software/create_models.py

Other models can be found at Hosted Models

For executing a models is necessary to run:

$ sudo python3.5 ./dtpu/software/run_model.py

The already quantized model must be present in the same folder of the previous script. Moreover, sudo is necessary for being able to program the FPGA witht the pynq python package.

The shared library for using the accelerator has been created according to Tensorflow Delegate . The API can be checked into the /dtpu/software/create_library.py (a more detailed explanation will be done).

Documentation

  • IN PROGRESS

Tests

For testing the solo accelerator you can use:

$ sudo python3.5 ./dtpu/run_dtpu.py

Useful Link

Reach out to me at one of the following places!

License

GNU General Public License v3.0