Giter Site home page Giter Site logo

shiftnet_cuda_v2's Introduction

Shift Operation CUDA Implementation

created by Peter Jin

Tradeoffs and further analysis can be found in the paper. If you find this work useful for your research, please consider citing:

@inproceedings{shift,
    Author = {Bichen Wu and Alvin Wan and Xiangyu Yue and Peter Jin and Sicheng Zhao and Noah Golmant and Amir Gholaminejad and Joseph Gonzalez and Kurt Keutzer},
    Title = {Shift: A Zero FLOP, Zero Parameter Alternative to Spatial Convolutions},
    Journal = {arXiv:1711.08141},
    Year = {2017}
}

Uses of Shift:

Installation

If you have included this shift repository as a submodule in a separate repository, feel free to skip down to step 5.

  1. If you have not already, setup a virtual environment with Python3, and activate it.
virtualenv shift --python=python3
source shift/bin/activate

Your prompt should now be prefaced with (shift), as in

(shift) [user@server:~]$ 
  1. Install pytorch and torchvision. Access pytorch.org, scroll down to the "Getting Started" section, and select the appropriate OS, package manager, Python, and CUDA build. For example, selecting Linux, pip, Python3.5, and CUDA 8 gives the following, as of the time of this writing
pip3 install http://download.pytorch.org/whl/cu80/torch-0.3.0.post4-cp35-cp35m-linux_x86_64.whl 
pip3 install torchvision
  1. Clone this repository.
git clone [email protected]:peterhj/shiftnet_cuda_v2.git
  1. cd into the root of this repository.
cd shiftnet_cuda_v2
  1. Install the Python requirements for this package.
pip3 install -r requirements.txt
  1. Compile the Shift Layer implementation in C.
make

Getting invalid_device_function? Update the architecture code in models/shiftnet_cuda_v2/Makefile, currently configured for a Titan X. e.g., A Tesla K80 is sm-30.

Your custom CUDA layer is now installed.

Test

To check that the build completed successfully, run the test script

python test_shiftnet.py

After ~3s, the script should output a number of different tensors, where the last tensor has non-zero values only in the first column.

Columns 13 to 17
   89     0     0     0     0
  107     0     0     0     0
  125     0     0     0     0
  143     0     0     0     0
  161     0     0     0     0
  179     0     0     0     0
  197     0     0     0     0
  215     0     0     0     0
  233     0     0     0     0
  251     0     0     0     0
  269     0     0     0     0
  287     0     0     0     0
  305     0     0     0     0
  323     0     0     0     0
    0     0     0     0     0
    0     0     0     0     0
    0     0     0     0     0
    0     0     0     0     0
[torch.FloatTensor of size 18x18]

shiftnet_cuda_v2's People

Contributors

alvinwan avatar peterhj avatar

Stargazers

Gangming Zhao avatar

Watchers

James Cloos avatar Gangming Zhao avatar

Forkers

gangmingzhao

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.