Giter Club home page Giter Club logo

Comments (6)

JoeLoser avatar JoeLoser commented on July 22, 2024 2

Internally, @abduld mentioned "we do not support fp16 one it". He likely meant to post that comment in the spot on Linear so the comment would get synced externally/be visible here.

from mojo.

YichengDWu avatar YichengDWu commented on July 22, 2024 1

@abduld Why closing this?

from mojo.

soraros avatar soraros commented on July 22, 2024

This bug is only triggered if two (or more) floating point types other than float64 are used.

The nextafter function is implemented roughly as follows:

fn nextafter(arg0: SIMD[type], arg1: SIMD[type]) -> SIMD[type]:
    fn _float32_dispatch[...](...) -> ...: ...
    fn _float64_dispatch[...](...) -> ...: ...

    constrained[type.is_floating_point(), "input type must be floating point"]()
    @parameter
    if type is DType.float64:
        return _simd_apply[_float64_dispatch](arg0, arg1)
    else:
        return _simd_apply[_float32_dispatch](arg0, arg1)

Types other than float32 fall into the else branch. This design pattern is prevalent in the standard library (e.g., math.mojo), and we should fix it everywhere.

We could either cast other float types to f32 or f64 as a fallback or forbid them altogether using the constrained function. I'm not sure which approach is preferred. CC: @abduld

from mojo.

YichengDWu avatar YichengDWu commented on July 22, 2024

Using test_nextafterDType.float16 alone seems to work fine. So neither falling back to float32 nor adding constrains sounds like the right solution to me.

from mojo.

soraros avatar soraros commented on July 22, 2024

I don't mean to ban them literally, rather we need to make clear in the implementation which one of the dispatches actually exists. If it does work, I suspect it works accidentally. For instance, atan2[float16] produces the wrong result.

Again, it's hardly nextafter's problem.

from mojo.

YichengDWu avatar YichengDWu commented on July 22, 2024

Good to know that. Any reasons for only two dispatches exist for now?

from mojo.

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.