Giter Site home page Giter Site logo

Problems with casting about numba HOT 3 CLOSED

numba avatar numba commented on July 22, 2024
Problems with casting

from numba.

Comments (3)

jriehl avatar jriehl commented on July 22, 2024

The float() built-in is not currently handled by the compiler, and we don't currently have code to cleanly identify when a built-in function is not supported.

Numba does handle implicit casts, however. You should only have to say result[i] += avg / N, and Numba should cast N to a floating-point value.

I can't currently speak to the segmentation fault, but I'll definitely add a test case and see if I can reproduce all of this.

from numba.

ovillellas avatar ovillellas commented on July 22, 2024

Related to this: I've run in several problems when working with number literals. I've got problems when trying to generate code for functions that do literals. For example, the following function works fine when generating code with d[:], d[:] input and output, but will fail with f[:], f[:] ones.

def twice(X, D):
    M = X.shape[0]
    for i in range(M):
        D[i] = 2.0 * X[i]

ValueError: Unsupported cast (from <Variable(val=<llvm.core.Instruction object at 0x10984aa50>, _llvm=<llvm.core.Instruction object at 0x10984aa50>, typ='f32')>.typ to 'f64')

Note that this does not happen if I use 2 instead of 2.0.

Something similar happens with the following function:

def pow2(X,D):
    M = X.shape[X]
    for i in range(M):
        D[i] = X[i] ** 2

No matter what combination of input types I try to use, code-generation fails with an "Unsupported Cast".

from numba.

markflorisson avatar markflorisson commented on July 22, 2024

This issue has been fixed for some time now, so I'm closing it.

from numba.

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.