Giter Club home page Giter Club logo

Comments (1)

georgedorn avatar georgedorn commented on May 27, 2024

Some quick findings from some naive njit-slapping:

  • it may be possible, but it's nowhere near as simple as applying @njit (or @jit where that fails). the code will need some restructuring to isolate functionality into numpy-only sections vs python-containing sections.
  • in particular, quite a few numpy methods are not implemented in numba. array.pad() and np.packbits() (in a PR) are noteworthy examples.
  • numba doesn't support the yield keyword, so all_rotations() will need to be rewritten to return an array of copies of the cubes, rather than doing in-place modifications of the cubes. The speedups of numba will need to exceed the speedups of doing in-place modifications rather than copying the cube 24 times. ETA: Removing yield from this and applying @jit makes no speed difference. @njit may help, but it balks at np.rot90() so another implementation would need to be found.
  • applying @njit to crop_cube() and @jit to the packbits() version of rle(), generate_polycubes() and expand_cube() does help. At n=9, there's a time reduction from 70.83s to 48.748s. As n increases, the reduction should only improve, as the compilation time is a fixed amount of overhead for each run.

This may be worthwhile, but is easier said than done.

ETA: A minimal-effort implementation of this change is: https://github.com/georgedorn/cubes/tree/trial/numba This isn't particularly ready to go, but it does have the speedup from above and produces correct results. If somebody wants to take this an run with it, I suspect there are some deep optimizations to be done yet by doing the work to replace @jit with @njit.

from cubes.

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.