Fix reallocation of D buffer in gemm
Merge pull request #3106 from LeszekSwirski:fix-gemm-buf-allocate