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