Giter VIP home page Giter VIP logo

nnpack.torch's Introduction

Torch FFI-bindings for NNPACK

NNPACK is a fast CPU implementation of convolution operations for training ConvNets:

https://github.com/Maratyszcza/NNPACK

The bindings are fully working and tested against nn version. Only single precision supported. Make sure you have AVX2 compatible Skylake/Broadwell/Haswell CPU.

Limitations of NNPACK:

  • there is no scale parameter on accGradParameters call

Installation

Follow installation steps at https://github.com/Maratyszcza/NNPACK to generate libnnpack.so and place where LD_LIBRARY_PATH can find it.

Then do

luarocks install https://raw.githubusercontent.com/szagoruyko/nnpack.torch/master/nnpack-scm-1.rockspec

Conversion between nnpack and nn

Similar to cudnn.convert in cudnn.torch easy backend switching is supported. To switch to nnpack just do:

nnpack.convert(net, nnpack)

There will be no memory copy, just metatables will be swapped.

Credits

Thanks to @Maratyszcza for adding the option to generate shared NNPACK library.

nnpack.torch's People

Contributors

szagoruyko 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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nnpack.torch's Issues

Cannot convert 'string' to 'enum nnp_status'

Hello,

Thank you very much for providing this. I'm having trouble getting it working on Linux. I built all the prerequisites, and the shared library is available, and when I add the line,

require 'nnpack'

to an otherwise working lua script, I get this:

/home/torch/torch/install/bin/luajit: /home/torch/torch/install/share/lua/5.1/trepl/init.lua:384: /home/torch/torch/install/share/lua/5.1/nnpack/init.lua:10: cannot convert 'string' to 'enum nnp_status'
stack traceback:
        [C]: in function 'error'
        /home/torch/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
        neural_style_nnpack.lua:5: in main chunk
        [C]: in function 'dofile'
        ...orch/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:145: in main chunk
        [C]: at 0x004064d0

Any help or insight would be greatly appreciated, and thank you for providing this.

SpatialConvolution_forward_single test failing

I am on OSX El Capitan, clang-602.0, nnpack compiled just fine and I was able to convert a network to the nnpack backend. However tests are failing:

» th test.lua
Running 3 tests
1/3 SpatialConvolution_forward_batch .................................... [PASS]
2/3 SpatialConvolution_forward_single ................................... [WAIT][1]    22043 segmentation fault  th test.lua

I was able to forward only a batch input through my model, but not an individual example, basically confirming the results of the test.

Error in NNPACK: cdata<enum nnp_status>: 51 (nnp_initialize)

Hello,
I just installed NNPACK of latest git and nnpack.torch and am geting the following error:

$ th

  ______             __   |  Torch7                                        
 /_  __/__  ________/ /   |  Scientific computing for Lua.
  / / / _ \/ __/ __/ _ \  |  Type ? for help                               
 /_/  \___/_/  \__/_//_/  |  https://github.com/torch        
                          |  http://torch.ch                 

th> require 'nnpack'
/home/esimo/torch/install/share/lua/5.1/trepl/init.lua:384: /home/esimo/torch/install/share/lua/5.1/nnpack/init.lua:11: Error in NNPACK: cdata<enum nnp_status>: 51 (nnp_initialize)
stack traceback:
        [C]: in function 'error'
        /home/esimo/torch/install/share/lua/5.1/trepl/init.lua:384: in function 'require'
        [string "_RESULT={require 'nnpack'}"]:1: in main chunk
        [C]: in function 'xpcall'
        /home/esimo/torch/install/share/lua/5.1/trepl/init.lua:651: in function 'repl'
        ...simo/torch/install/lib/luarocks/rocks/trepl/scm-1/bin/th:199: in main chunk
        [C]: at 0x00405d50

I'm assuming the API changed or something. Would it be possible to know what revision of NNPACK was last used with nnpack.torch to know compatibility?

By the way, I had to change the last lines of ffi.lua to the following so it uses the system nnpack.so and not a local one.

local C = ffi.load'nnpack'
--local C = ffi.load'./libnnpack.so'

Thanks.

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.