Last active
          October 26, 2020 12:57 
        
      - 
      
- 
        Save nschloe/8bc015cc1a9e5c56374945ddd711df7b to your computer and use it in GitHub Desktop. 
    einsum is faster if the tail survives
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import perfplot | |
| import numpy | |
| def setup(n): | |
| a = numpy.random.rand(n, 3) | |
| b = numpy.ascontiguousarray(a.T) | |
| return a, b | |
| def einsum_i(data): | |
| return numpy.einsum("ij,ij->i", data[0], data[0]) | |
| def einsum_j(data): | |
| return numpy.einsum("ij,ij->j", data[1], data[1]) | |
| perfplot.show( | |
| setup=setup, | |
| kernels=[einsum_i, einsum_j], | |
| n_range=[2 ** k for k in range(26)], | |
| relative_to=1, | |
| ) | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment