For EE 372 @ Stanford
Fast ANN Fieldious is a hardware accelerator for approximate nearest neighbor fields (ANN). The following repository is our Verilog design and verification files for this accelerator.
Our goal is to find nearest neighbors in Image B for a given Image A. This is a very important task for computer vision, optical flow, video compression, etc. However, it is a very computationally expensive algorithm. Interestingly, the most popular algorithm (propagation assisted kd-tree) lends itself well to hardware acceleration since it can be pipelined and executed in parallel. Thus the idea for Fast-ANN-Fieldious was born.
More details of this problem statement and its implementation can be found in the links below. Schematics for each block can be found in the Design Review link. A top level diagram of all blocks can be seen below:
- Chris Calloway
- Jake Ke
https://docs.google.com/presentation/d/1eATEbHkYKuJgkEudkhe2r2xmGzlnZk65wf9D-JNxt4s/edit?usp=sharing
https://docs.google.com/presentation/d/1Ie0uCnQg5wL7kaqn-tUW8gMvX_XnOqE4hdrijEjCLVE/edit?usp=sharing
- Install/Activatve vcs (Farmshare specific instructions below)
- git clone https://github.com/Chris-Not-Mikey/Fast-ANN-Fieldious.git
- Install packages needed for gold model (see below)
- /farmshare/home/classes/ee/admin/software/bin/centos.sh
- module load base
- module load vcs
The first two steps are optional but highly recommended
- python3 -m venv venv
- source venv/bin/activate.csh
- pip install --upgrade pip (may be needed for matplotlib)
- pip install kdtree
- pip install matplotlib
- pip install scikit-learn
- pip install opencv-python
- pip install tensorflow
The following will run the gold model, all unit tests, and final image reconstruction test on the default set of test vectors.
- cd Fast-ANN-Fieldious
- python3 runtests.py
runtests.py is based on the autograder from 272. Thus, most of the same commands will work. In particular -v can be specified for verbose mode to show assertion matches and other display outputs.
To specify which test vectors (images) to run (other than the default), included the following flag: -i "imageA" "imageB"
Example:
- python3 runtests.py -v -i "stick1" "stick2"
This will run all the tests in verbose mode, using the "stick figure" test vectors (as seen above) instead of the default test vectors.
All images can be found in "data/gold_data" For ease of use, each image pair (test vector image A and image B pair) is reproduced below:
- basketball1, basketball6
- basketball_far1, basketball_far250
- flow1smallest, flow6smallest
- frame1ball_30, frame2ball_30
- simple1, simple2
- stick1, stick2
- walking1, walking12
- walking_far1, walking_far74
Note: do NOT include .png in filename
A single test can be run (and thus a particular .vcd file can be generated) and viewed with gtkwave as follows:
- python3 runtests.py [test_name] -v
- gtkwave dump.vcd &
Example:
- python3 runtests.py agg -v
- gtkwave dump.vcd &
test_name must be a string that matches part of the test name specified in runtests.py. A list of all test names (and a brief description) is included below
- "gold" -- runs Gold Model which also generates test vectors for particular image pair (necessary to run first if testing new test vectors)
- "test_top" -- top level and FSM unit test (full pipeline test)
- "internal_node" -- internal node unit test
- "internal_node_tree" -- internal node tree unit test (search containing leaf algo)
- "sorted_list" -- sorted list unit test
- "sorter" -- Bitonic sorter unit test
- "l2_kernel" -- l2 kernel unit test
- "query_row_double_buffer" -- SRAM unit test
- "wishbone" -- wishbone interface unit test
- "bluespec" -- blue spec async fifo (IP) unit test
- "agg" -- aggregator (IP) unit test
- "l2_reconstruct" -- runs final l2 score + image reconstruction and compares to gold results (necessary to run after test_top so that correct results are compared)