@@ -38,48 +38,48 @@ def test_np_einsum():
3838 a = np .ones (64 ).reshape (2 ,4 ,8 )
3939 args = ['ijk,ilm,njm,nlk,abc->' , a , a , a , a , a ]
4040 cost = measure_cost (500 , np .einsum , * args )
41- print ("Basic einsum: {} ms" . format ( cost * 1000 ) )
41+ print (f "Basic einsum: { cost * 1000 } ms" )
4242
4343 # Sub-optimal einsum
4444 # cost = measure_cost(500, np.einsum, *args, optimize='optimal')
4545 # print("Optimal einsum: {} ms".format(cost * 1000))
4646
4747 # Greedy einsum
4848 cost = measure_cost (500 , np .einsum , * args , optimize = True )
49- print ("Greedy einsum: {} ms" . format ( cost * 1000 ) )
49+ print (f "Greedy einsum: { cost * 1000 } ms" )
5050
5151 print ("RNN Use Case:" )
5252 a = np .random .uniform (0 , 1 , size = (64 , 128 , 512 ))
5353 b = np .random .uniform (0 , 1 , size = (128 , 512 , 2 , 2 ))
5454 args = ['bij, ijkl->bkl' , a , b ]
5555 cost = measure_cost (2 , np .einsum , * args , optimize = True )
56- print ('Greedy einsum: {} ms' . format ( cost * 1000 ) )
56+ print (f 'Greedy einsum: { cost * 1000 } ms' )
5757 cost = measure_cost (2 , np .einsum , * args )
58- print ('Basic einsum: {} ms' . format ( cost * 1000 ) )
58+ print (f 'Basic einsum: { cost * 1000 } ms' )
5959
6060 print ('Inner Product:' )
6161 a = np .ones (6000000 )
6262 b = np .ones (6000000 )
6363 args = [a , b ]
6464 cost = measure_cost (50 , np .tensordot , * args , axes = ([0 ],[0 ]))
65- print ('Tensordot: {} ms' . format ( cost * 1000 ) )
65+ print (f 'Tensordot: { cost * 1000 } ms' )
6666 args = ['i, i' , a , b ]
6767 cost = measure_cost (50 , np .einsum , * args , optimize = True )
68- print ('Greedy einsum: {} ms' . format ( cost * 1000 ) )
68+ print (f 'Greedy einsum: { cost * 1000 } ms' )
6969 cost = measure_cost (50 , np .einsum , * args )
70- print ('Basic einsum: {} ms' . format ( cost * 1000 ) )
70+ print (f 'Basic einsum: { cost * 1000 } ms' )
7171
7272 print ('Matrix Product:' )
7373 a = np .ones (600000 ).reshape (200 , 3000 )
7474 b = np .ones (600000 ).reshape (3000 , 200 )
7575 args = [a , b ]
7676 cost = measure_cost (50 , np .tensordot , * args , axes = ([1 ],[0 ]))
77- print ('Tensordot: {} ms' . format ( cost * 1000 ) )
77+ print (f 'Tensordot: { cost * 1000 } ms' )
7878 args = ['ij, jk' , a , b ]
7979 cost = measure_cost (50 , np .einsum , * args , optimize = True )
80- print ('Greedy einsum: {} ms' . format ( cost * 1000 ) )
80+ print (f 'Greedy einsum: { cost * 1000 } ms' )
8181 cost = measure_cost (50 , np .einsum , * args )
82- print ('Basic einsum: {} ms' . format ( cost * 1000 ) )
82+ print (f 'Basic einsum: { cost * 1000 } ms' )
8383
8484
8585if __name__ == "__main__" :
0 commit comments