Git Product home page Git Product logo

column-combine's Introduction

Packing Sparse Convolutional Neural Networks for Efficient Systolic Array Implementations: Column Combining Under Joint Optimization

Abstract

This paper describes a novel approach of packing sparse convolutional neural networks into a denser format for efficient implementations using systolic arrays. By combining multiple sparse columns of a convolutional filter matrix into a single dense column stored in the systolic array, the utilization efficiency of the systolic array can be substantially increased (e.g. 8x) due to the increased density of nonzero weights in the resulting packed filter matrix. In combining columns, for each row, all filter weights but the one with the largest magnitude are pruned. The remaining weights are retrained to preserve high accuracy. We study the effectiveness of this joint optimization for both high utilization efficiency and classification accuracy with ASIC and FPGA designs based on efficient bit-serial implementations of multiplier-accumulators. We demonstrate that in mitigating data privacy concerns the retraining can be accomplished with only fractions of the original dataset (e.g., 10% for CIFAR-10). We present analysis and empirical evidence on the superior performance of our column combining approach against prior arts under metrics such as energy efficiency (3x) and inference latency (12x).

A lightning talk on the paper can be found here.

Training CNNs with Column Combining

Use train.py to train a CNN with column combining. To make it easier to specify the number of layers and number of filters per layer, we parameterize the CNN into commandline arguments. The --filters flag takes a list of integers, correspondings to the number of filters in the layer. This is accompanied by the --layers flag, which determines how many layers are used for each number of filters. For instance, if the flags are --filters 128 256 512 --layers 6 6 6, then the CNN with have a total of 18 convolutional layers (plus one initial layer), with the first 6 layers having 128 filters, then next 6 with 256, and the final 6 with 512.

Column combining has two main hyperparameters (alpha and gamma) which determine both the amount of weight which are pruned and how efficienctly the sparse matricies can be packed into a denser format. Gamma is set for all layers in a CNN (controlled by the --gamma flag). Alpha is set a per layer basis to account for different layers sizes in the CNN. This is set by the --groups flag, and follows the same convention as --filters and --layers.

Training a CIFAR-10 Model

A CIFAR-10 model can be trained using the following:

python train.py --dataset-root /hdd1/datasets/ --dataset cifar10 --input-size 32 --n-class 10 --aug + --save-path cifar10-cc.pth --batch-size 128 --epochs 300 --lr 0.1 --l1-penalty 1e-7 --gamma 1.75 --filters 128 256 512 --layers 6 6 6 --strides 1 2 2 --groups 1 4 8 --layer-type shift --print-freq 50

column-combine's People

Contributors

bradmcdanel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

column-combine's Issues

RuntimeError: Ninja is required to load C++ extensions

Hi @BradMcDanel , I have installed pytorch==1.3.1, ninja==1.10.2, but I still came across the following errors when I ran the cifar10 example as shown in readme. Is it possibly some dependencies issue?

Traceback (most recent call last):
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 893, in verify_ninja_availability
    subprocess.check_call('ninja --version'.split(), stdout=devnull)
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/subprocess.py", line 306, in check_call
    retcode = call(*popenargs, **kwargs)
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/subprocess.py", line 287, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ninja': 'ninja'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/zhongad/PycharmProjects/HTKung/train.py", line 17, in <module>
    import util
  File "/home/zhongad/PycharmProjects/HTKung/util.py", line 12, in <module>
    import net
  File "/home/zhongad/PycharmProjects/HTKung/net.py", line 15, in <module>
    sources=['kernels/shift_cuda.cpp', 'kernels/shift_cuda_kernel.cu'])
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 661, in load
    is_python_module)
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 830, in _jit_compile
    with_cuda=with_cuda)
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 853, in _write_ninja_file_and_build
    verify_ninja_availability()
  File "/home/zhongad/.conda/envs/test_mat/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 895, in verify_ninja_availability
    raise RuntimeError("Ninja is required to load C++ extensions")
RuntimeError: Ninja is required to load C++ extensions

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.