Skip to content

dotv: float32 rounding error is 10x of NumPyΒ #142

@crusaderky

Description

@crusaderky

I found a use case where the rounding error in float32 is ~1.3e-3, compared to ~1.3e-4 of NumPy.

    import numpy as np
    from blis import dotv

    A64 = np.full((95, ), fill_value=40.09845, dtype=np.float64)
    A64[0] = 0.0
    B64 = np.full((95, ), fill_value=2.0, dtype=np.float64)
    B64[1] = -98.0
    B64[2] = -86.0
    A32 = A64.astype(np.float32)
    B32 = B64.astype(np.float32)

    np_f64 = A64.dot(B64)  # np.float64(0.0)
    blis_f64 = dotv(A64, B64)  # 0.0
    np_f32 = A32.dot(B32)  # np.float32(-0.00012207031)
    blis_f32 = dotv(A32, B32)  # -0.001220703125

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions