Skip to content

Nested conversion of Float64 to Float32 #650

@cortner

Description

@cortner

When moving an Array{Float64, N} to the device, the floating point type is automatically converted,

using Metal
mtl( rand(1000) )  
# MtlVector{Float32, ...}

But for an array of static arrays, or dual numbers, etc, this conversion fails:

using StaticArrays 
mtl( rand( SVector{2, Float64}, 1000 ) )
# ERROR: Metal does not support Float64 values, try using Float32 instead

Conversion of arrays of static arrays does work if the number type is Float32,

mtl( rand( SVector{2, Float32}, 1000 ) )
# MtlVector{SVector{2, Float32}, ...}

I don't particularly mind whether I have to manually ensure that I use the correct number types, or whether Metal auto-converts for me. I see advantages either way. But the current behaviour is inconsistent.

I may be able to help with a PR that tackles StaticArrays, ForwardDiff (dual numbers) and HyperDuals but would probably need some pointers on how to approach this correctly without wasting everybody's time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions