No, you won’t be able to modify mm if you think it is about such loops. I’ll point you to sources, but this is just to give you an idea
addmm_out_cuda_impl 3
addmm_impl_cpu_ 3
note that there are like 5-10 wrappers above these routines in ATen (and mm dispatches to addmm there), and they still dispatch to an external blas library (that will process avx/cuda blocks, instead of a loop like that)
PS if you’re using CUDA, amortization from parallelism may make your efforts have only a minor effect.