This is a performance bug and should be fixed. I’ve written up a bug report here:

  
      github.com/pytorch/pytorch
  
  
    



Issue: matmul uses too much memory in some batched cases 133


	
	opened by colesbury
	on 2019-04-04
	
	
	


🐛 Bug
PyTorch 1.1.0a0+c3e3c5c. The GPU times reported are on a P100.
In this case matmul uses about 12 GB of memory when...




  
  
    
    
  
  


@liangbright, In general broadcasting does not usually expand a tensor “physically” (in memory), but in this case matmul unnecessarily expands the tensor by calling “contiguous()” on the expanded tensor.