I need to do in-place summations of a transposed matrix and I get memory allocation in the process. For example, running function test of the following code
function test_sum_transpose(b, a)
sum!(b, a')
end
function test_sum(b, a)
sum!(b, a)
end
function test()
a = [1 2 3; 3 4 5]
b = [0.0, 0.0, 0.0]; @time test_sum_transpose(b, a)
b = [0.0, 0.0]; @time test_sum(b, a)
return nothing
end
Also, you don’t have to create all these functions to test simple things like this. In this case it seems that there is an allocation from forming the adjoint: