Ar = A.reshape(-1, A.shape[2])
sorted_idx = np.lexsort(Ar.T)
sorted_Ar = Ar[(sorted_idx), :]
unq_out = np.any(np.diff(sorted_Ar, axis=0), 1).sum() + 1
Efficiently count the number of occurrences of unique subarrays in NumPy?