def nsort(a, b): fa = os.path.basename(a).split('.') fb = os.path.basename(b).split('.') elements_to_remove = [] assert len(fa) == len(fb) for i in range(0, len(fa)): if fa[i] == fb[i]: elements_to_remove.append(fa[i]) for e in elements_to_remove: fa.remove(e) fb.remove(e) assert len(fa) == len(fb) assert len(fa) == 1 fa = keep_only_digits(fa[0]) fb = keep_only_digits(fb[0]) if fa < fb: return -1 if fa == fb: return 0 if fa > fb: return 1
def reduce_filename(f): r''' Expects something like /tmp/tmpAjry4Gdsbench/test.weights.e5.XXX.YYY.pb Where XXX is a variation on the model size for example And where YYY is a const related to the training dataset ''' f = os.path.basename(f).split('.') if f[1] == 'aot': return 'AOT:' + str(keep_only_digits(f[-3])) else: return keep_only_digits(f[-3])