Closed avik-pal closed 4 months ago
using Enzyme
@noinline function _bcs2(x, y)
x != y && error(2)
return x
end
@noinline function _affine_normalize(x::AbstractArray)
# _axes = broadcast_shape(axes(x), axes(x)) #Broadcast.combine_axes(x, x)
_axes = _bcs2(axes(x), axes(x))
i = Broadcast.Broadcasted(Base.Broadcast.DefaultArrayStyle{2}(), +, (x,), _axes)
dest = similar(Array{Float32}, _axes)
bc = convert(Broadcast.Broadcasted{Nothing}, i)
# mycopyto!(dest, bc)
copyto!(dest, bc)
return x
end
function loss_function(x)
return _affine_normalize(x)[1]
end
x = rand(Float32, 2, 3)
loss_function(x)
Enzyme.gradient(Reverse, loss_function, x)
Fixed in main
This used to work before v0.12.8