Giter Site home page Giter Site logo

Comments (5)

btomtom5 avatar btomtom5 commented on May 28, 2024

I don't think that converting layers in bnn.torch to a cpu layer is going to work without some effort. If you look at the implementation of the layers in bnn.torch, they are implemented in Nvidia CUDA. You are going to have to write the corresponding cpu code yourself and use this function to swap it out:

def replace_module(module, check_fn, create_fn):
    if not hasattr(module, 'modules'):
        return
    if module.modules is None:
        return
    for i in range(len(module.modules)):
        m = module.modules[i]
        if check_fn(m):
            module.modules[i] = create_fn(m)
        replace_module(m, check_fn, create_fn)

from binary-face-alignment.

vinayak618 avatar vinayak618 commented on May 28, 2024

Thank you for reply btomtom5.
I understand that, But since the base code for bnn.torch is written in Nvidia Cuda.
Can I atleast convert it to "cudnn."
So then I can use cudnn.torch to convert it to equivalent nn

from binary-face-alignment.

btomtom5 avatar btomtom5 commented on May 28, 2024

Hmmm. I don't think that works because the lua convert function relies on the destination module nn in this case to have the corresponding classes SpatialConvolution and Binary. nn does have a SpatialConvolution defined but it needs to decode the weights before it can do the convolution. bnn.SpatialConvolution encodes the 32 weights of 0 and 1 as a single 32 bit integer.

Why do you want to run it in cpu only mode? I suggest renting out an ec2 instance with gpu support.

from binary-face-alignment.

vinayak618 avatar vinayak618 commented on May 28, 2024

Yeah.
So the only alternative would be writing a CPU equivalent of bnn.torch?

from binary-face-alignment.

btomtom5 avatar btomtom5 commented on May 28, 2024

That's correct, but you only need to write the forward pass of it.

  1. decode the weights from int32 to binary
  2. perform regular spatial convolution from the binary weights || perform bitwise operation which is much more performant.

After you do this, you should search through the loaded module and replace them with your newly written module using the code I shared above. You also have to make sure that the weights are migrated over though.

from binary-face-alignment.

Related Issues (12)

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.