Download presentation
Presentation is loading. Please wait.
Published bySusanti Gunawan Modified over 5 years ago
1
CS 295: Modern Systems Lab2: Convolution Accelerators
Sang-Woo Jun 2019 Spring
2
Lab 2 Goals Implement a hardware accelerator for convolution
Ostensibly useful for the convolution layers of a neural network Weight stationary design Template and testbench framework written in Bluespec Weight stationary convolution for a row in the convolution Partial sum of a previous activation row if any Partial sum for stored for next activation row, or final sum
3
Intuitive Example of a Convolution: Sobel Edge Detection Filter
Simple convolution filter for emphasizing edges in an image Two convolutions sweep over the input image The output of the two filters are joined after convolutions are completed Images from Wikipedia
4
Framework Details https://github.uci.edu/swjun/cs295_19s
Lab 2 files in sub-directory “convolution” Two Bluespec files Top.bsv : Testbench framework. No need to edit Filter.bsv : Convolution filter implementation. You need to edit this Three C++/h files bdpi.cpp : Testbench framework that emulates data input/output createbmp.cpp/h : Creates bmp files from edge-detected output One data file datain.bin : 64 32*32 images from the CIFAR-10 dataset
5
In Filter.bsv mkFilter exposing parameterized FilterIfc interface
input channels, filter count, filter width setWeight fills in a multidimensional vector “weights” setWeightDone is called after testbench enters all weights put is called with a input data vector get is called to retrieve convolved data
6
Things To Keep in Mind put is called repeatedly with a vector of channels per pixel (R,G,B) There is no delineation between images. All images are 32*32 pixels It is first converted to greyscale by simply averaging RGB values (provided in code) Need to add zero padding around the images so that the output is the same dimension as the input For simplicity, just add zero pixels around the smaller convolved output image For sobel filter: Input is 32*32*3 per image, and output should be (for sobel filter) 32*32*2 per image
7
Tips Pixels streamed through N row buffers (where N is width of filter) Can use mkBRAMFIFO’s For Sobel filter, each PE box in Fig. 3 should ideally implement 6 PEs, for 3 columns per each row, for two filters
8
Development Environment
Server at “orthanc.ics.uci.edu” Login details will be ed to you Bluespec and licenses already installed vim syntax files for Bluespec included with this document Copy to respective directories in ~/.vim Required environment variables in ~/setupbsv.sh Already source’d in .bashrc
9
Building And Running “make” ./bsim/obj/bsim Output: “outXX.bmp”
32*32 pixel greyscale Currently just greyscale of input image Suggest saving them for comparison
10
Submission Same as lab 1 Submit Filter.bsv, and a short write-up (1+ paragraph is fine) describing how you did it Please to me with title [CS295] lab2 – ucinetid
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.