cyclops-community / ctf

Cyclops Tensor Framework: parallel arithmetic on multidimensional arrays
Other
199 stars 53 forks source link

ctf-einsum.py:78: DeprecationWarning: `np.complex` is a deprecated alias for the builtin `complex`. #129

Closed ghost closed 2 years ago

ghost commented 3 years ago

Sorry to spam one more time,

I revisited some example tested before in https://github.com/cyclops-community/ctf/issues/126

not sure if I should reply under that thread

import numpy as np
import time
import ctf
import opt_einsum

N = 30

T1 = np.random.rand(N, N, N, N)
T2 = np.random.rand(N, N, N, N) 
T3 = np.zeros((N,N,N,N))  

# symmetrize T1/T2
for a in range(N):
  for b in range(a+1):     #include a
    for c in range(N):
      for d in range(N):
        T1[b,a,d,c] = T1[a,b,c,d]
        T2[b,a,d,c] = T2[a,b,c,d]        

# exam symmetry        
for a in range(N):
  for b in range(N):
    for c in range(N):
      for d in range(N):
        if abs(T1[b,a,d,c] - T1[a,b,c,d] ) > 1.e-5:  
          print('T1', a,b,c,d, T1[b,a,d,c], T1[a,b,c,d])
        if abs(T2[b,a,d,c] - T2[a,b,c,d] ) > 1.e-5:  
          print('T2', a,b,c,d, T2[b,a,d,c], T2[a,b,c,d])

start = time.time()
out = opt_einsum.contract('ABab,abCD->ABCD', T1, T2)#, optimize="dynamic-programming")
end = time.time()

print('time opt_einsum',end - start)
#print(out[0,1,2,3],out[1,0,3,2])

start = time.time()
out = np.einsum('ABab,abCD->ABCD', T1, T2)
end = time.time()

print('time einsum',end - start)
#print(out[0,1,2,3],out[1,0,3,2])

start = time.time()
out = np.einsum('ABab,abCD->ABCD', T1, T2, optimize=True)
end = time.time()

print('time einsum optimize',end - start)
print(out[0,1,2,3],out[1,0,3,2])

start = time.time()
out3 = ctf.einsum('ABab,abCD->ABCD', T1, T2)
end = time.time()

print('time ctf',end - start)
#print(out[0,1,2,3],out[1,0,3,2])

A = ctf.tensor([N,N,N,N],sym=[ctf.SYM.NS,ctf.SYM.NS,ctf.SYM.SY,ctf.SYM.NS])
B = ctf.tensor([N,N,N,N],sym=[ctf.SYM.NS,ctf.SYM.NS,ctf.SYM.SY,ctf.SYM.NS])
C = ctf.tensor([N,N,N,N],sym=[ctf.SYM.NS,ctf.SYM.NS,ctf.SYM.SY,ctf.SYM.NS])

A = T1
B = T2

start = time.time()
C = ctf.einsum('ABab,abCD->ABCD', A, B)
end = time.time()

print('time ctf symmetrize',end - start)
print(C[0,1,2,3],C[1,0,3,2])

I got ctf-einsum.py:78: DeprecationWarning: `np.complex` is a deprecated alias for the builtin `complex`. To silence this warning, use `complex` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.complex128` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations out3 = ctf.einsum('ABab,abCD->ABCD', T1, T2) ctf-einsum.py:78: DeprecationWarning: `np.bool` is a deprecated alias for the builtin `bool`. To silence this warning, use `bool` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool_` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

ctf-einsum.py is the name of the file, I am not sure how it triggered np.bool vs bool.

The last part of the output is OpenBLAS : munmap failed:: Invalid argument error code=22, release->address=0x7f415bdf0 is there any solution with OpenBLAS or I should use lblas?

I tried make python_test, also found many deprecation warnings, without munmap failed, i.e.,

OK
echo "Cyclops Python tests completed."
Cyclops Python tests completed.

seems the BLAS is OK.

ghost commented 2 years ago

By adding import warnings warnings.filterwarnings("ignore", category=DeprecationWarning) all warning/error messages are gone.