CS 295 Modern Systems Lab 2 Convolution Accelerators

CS 295: Modern Systems Lab 2: Convolution Accelerators Sang-Woo Jun 2019 Spring

Lab 2 Goals q Implement a hardware accelerator for convolution o Ostensibly useful for the convolution layers of a neural network o Weight stationary design o 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

Intuitive Example of a Convolution: Sobel Edge Detection Filter q Simple convolution filter for emphasizing edges in an image o Two convolutions sweep over the input image o The output of the two filters are joined after convolutions are completed Images from Wikipedia

Framework Details q https: //github. uci. edu/swjun/cs 295_19 s o Lab 2 files in sub-directory “convolution” q Two Bluespec files o Top. bsv : Testbench framework. No need to edit o Filter. bsv : Convolution filter implementation. You need to edit this q Three C++/h files o bdpi. cpp : Testbench framework that emulates data input/output o createbmp. cpp/h : Creates bmp files from edge-detected output q One data file o datain. bin : 64 32*32 images from the CIFAR-10 dataset

In Filter. bsv q mk. Filter exposing parameterized Filter. Ifc interface o o o input channels, filter count, filter width set. Weight fills in a multidimensional vector “weights” set. Weight. Done is called after testbench enters all weights put is called with a input data vector get is called to retrieve convolved data

Things To Keep in Mind q put is called repeatedly with a vector of channels per pixel (R, G, B) o There is no delineation between images. All images are 32*32 pixels o It is first converted to greyscale by simply averaging RGB values (provided in code) q Need to add zero padding around the images so that the output is the same dimension as the input o For simplicity, just add zero pixels around the smaller convolved output image o For sobel filter: Input is 32*32*3 per image, and output should be (for sobel filter) 32*32*2 per image

Tips q Pixels streamed through N row buffers (where N is width of filter) o Can use mk. BRAMFIFO’s q For Sobel filter, each PE box in Fig. 3 should ideally implement 6 PEs, for 3 columns per each row, for two filters

Development Environment q Server at “orthanc. ics. uci. edu” o Login details will be emailed to you o Bluespec and licenses already installed q vim syntax files for Bluespec included with this document o Copy to respective directories in ~/. vim q Required environment variables in ~/setupbsv. sh o Already source’d in. bashrc

Building And Running q “make” q. /bsim/obj/bsim q Output: “out. XX. bmp” o 32*32 pixel greyscale o Currently just greyscale of input image o Suggest saving them for comparison

Submission q Same as lab 1 o Submit Filter. bsv, and a short write-up (1+ paragraph is fine) describing how you did it o Please email to me with title [CS 295] lab 2 – ucinetid
- Slides: 10