Skip to content

mul! does not respect false as a strong zero #1399

@tam724

Description

@tam724

For e.g. Float16 where mul! (mat-vec) does not call BLAS, but the generic julia implementation, the resulting vector after mul! with α, β = false, false still contains NaNs.
Here's a MWE:

julia> using LinearAlgebra

julia> x, A, y = fill(NaN32, 2), fill(NaN32, 2, 2), fill(NaN32, 2)
(Float32[NaN, NaN], Float32[NaN NaN; NaN NaN], Float32[NaN, NaN])

julia> mul!(y, A, x, false, false) # stops the NaN propagation
2-element Vector{Float32}:
 0.0
 0.0

julia> x, A, y = fill(NaN16, 2), fill(NaN16, 2, 2), fill(NaN16, 2)
(Float16[NaN, NaN], Float16[NaN NaN; NaN NaN], Float16[NaN, NaN])

julia> mul!(y, A, x, false, false) # does NOT stop the NaN's
2-element Vector{Float16}:
 NaN
 NaN

julia> X, A, Y = fill(NaN16, 2, 2), fill(NaN16, 2, 2), fill(NaN16, 2, 2)
(Float16[NaN NaN; NaN NaN], Float16[NaN NaN; NaN NaN], Float16[NaN NaN; NaN NaN])

julia> mul!(Y, A, X, false, false) # however, matmatmul does
2×2 Matrix{Float16}:
 0.0  0.0
 0.0  0.0

I tried with julia 1.11.5 and 1.12.0-beta4.

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