【发布时间】:2022-10-23 18:18:48
【问题描述】:
矩阵乘法 Y = A * B 可以通过 mul!(Y, A, B) 来实现,以节省内存分配。但是穆尔!如果 Y = A 则不能使用。是否有类似的有效方法来计算 Y *= B?或者如果不是,什么是最有效的矩阵乘法 Y *= B
小工作示例:
n = 10
A = rand(n,n)
B = rand(n,n)
Y = zeros(n,n)
#mul! removes allocations
@allocated Y = A * B #896
@allocated mul!(Y, A, B) #0
#mul! can't be applied in this case
@allocated Y *= B #896
#desired function performance
@allocated mul_2!(Y, B) #0
在此先感谢您的帮助!
【问题讨论】:
标签: matrix julia matrix-multiplication memory-efficient