GithubHelp home page GithubHelp logo

Comments (5)

lvdmaaten avatar lvdmaaten commented on May 28, 2024 1

f3b82e8

from torchnet.

lvdmaaten avatar lvdmaaten commented on May 28, 2024

Okay, I will add this.

from torchnet.

Atcold avatar Atcold commented on May 28, 2024

@lvdmaaten: could you please also address my question about resize()?

from torchnet.

lvdmaaten avatar lvdmaaten commented on May 28, 2024

The resize() is not being called on the data itself, but on the GPU buffer the data is being copied into.

Copying data via :cuda() is inefficient because it does a malloc and a free each time you do it, and free is a blocking operation in CUDA. When your repeatedly copy data of the same size to the GPU, it is does much more efficient to pre-allocate a buffer on the GPU, and copy the data into that buffer. This is what the code is doing. However, the onSample function doesn't know for sure that the data always has the same size (for instance, the last batch of data may be smaller). To make sure we don't end up writing to memory we may not write to or end up with uninitialized memory, we do a resize() on the buffer to make sure it has the right size. When the buffer already had the right size (which is the case nearly always), the resize() doesn't do anything (it also doesn't cost anything). This way, we get the benefits of being dynamic whilst also be non-blocking nearly always.

from torchnet.

Atcold avatar Atcold commented on May 28, 2024

Oh, OK, I wasn't aware that resize() was transparent in case of already correct dimensionality.

from torchnet.

Related Issues (20)

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.