Using machine learning to improve dense and sparse matrix multiplication kernels