# Does Flux not support Float16 convolution operation (Flux.NNlib.conv) with CuArray?

**URL:** <https://discourse.julialang.org/t/does-flux-not-support-float16-convolution-operation-flux-nnlib-conv-with-cuarray/99640>\
**Category:** General Usage\
**Tags:** flux, machine-learning, zygote, convolution\
**Created:** [May 31, 2023, 2:44am UTC](https://discourse.julialang.org/t/does-flux-not-support-float16-convolution-operation-flux-nnlib-conv-with-cuarray/99640 "2023-05-31T02:44:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![guixien](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/guixien/32/34399_2.png) [@guixien](https://discourse.julialang.org/u/guixien)\
**Post date:** [May 31, 2023, 2:44am UTC](https://discourse.julialang.org/t/does-flux-not-support-float16-convolution-operation-flux-nnlib-conv-with-cuarray/99640/1 "2023-05-31T02:44:00Z")

</div>

```julia
using Flux, CUDA
struct filters{T <: Real} 
    f::AbstractArray{T,3}
    function filters{T}(f) where T <: Real
        new(f)
    end
end
Flux.@functor filters

```

And this works:

```julia
T = Float32
q = filters{T}(cu(rand(50, 1, 15)))
X = cu(randn(T, (100, 1, 4)))
S = cu(randn(T,(51,15,4)))
ps = Flux.params(q)
gs = gradient(ps) do
    sum(Flux.NNlib.conv(X, q.f, pad=0) - S)
end

```

But this doesn’t work:

```julia
T = Float16
q = filters{T}(cu(rand(50, 1, 15)))
X = cu(randn(T, (100, 1, 4)))
S = cu(randn(T,(51,15,4)))
ps = Flux.params(q)
gs = gradient(ps) do
sum(Flux.NNlib.conv(X, q.f, pad=0) - S)

```

which gives

> CUDNNError: CUDNN\_STATUS\_BAD\_PARAM (code 3)

---

<div class="post-metadata">

**Author:** ![mcabbott](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mcabbott/32/6603_2.png) [@mcabbott](https://discourse.julialang.org/u/mcabbott)\
**Post date:** [May 31, 2023, 3:48am UTC](https://discourse.julialang.org/t/does-flux-not-support-float16-convolution-operation-flux-nnlib-conv-with-cuarray/99640/2 "2023-05-31T03:48:24Z")

</div>

I think this is: [Float16 CUDA `conv` broken on 5D tensors · Issue #68 · FluxML/NNlibCUDA.jl · GitHub](https://github.com/FluxML/NNlibCUDA.jl/issues/68)
