Update NATS-Bench (tss version 0.8)
This commit is contained in:
		| @@ -4,3 +4,4 @@ from .flop_benchmark   import get_model_infos, count_parameters_in_MB | ||||
| from .affine_utils     import normalize_points, denormalize_points | ||||
| from .affine_utils     import identity2affine, solve2theta, affine2image | ||||
| from .hash_utils       import get_md5_file | ||||
| from .str_utils        import split_str2indexes | ||||
|   | ||||
							
								
								
									
										18
									
								
								lib/utils/str_utils.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								lib/utils/str_utils.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,18 @@ | ||||
|  | ||||
| def split_str2indexes(string: str, max_check: int, length_limit=5): | ||||
|   if not isinstance(string, str): | ||||
|     raise ValueError('Invalid scheme for {:}'.format(string)) | ||||
|   srangestr = "".join(string.split()) | ||||
|   indexes = set() | ||||
|   for srange in srangestr.split(','): | ||||
|     srange = srange.split('-') | ||||
|     if len(srange) != 2: | ||||
|       raise ValueError('invalid srange : {:}'.format(srange)) | ||||
|     if length_limit is not None: | ||||
|       assert len(srange[0]) == len(srange[1]) == length_limit, 'invalid srange : {:}'.format(srange) | ||||
|     srange = (int(srange[0]), int(srange[1])) | ||||
|     if not (0 <= srange[0] <= srange[1] < max_check): | ||||
|       raise ValueError('{:} vs {:} vs {:}'.format(srange[0], srange[1], max_check)) | ||||
|     for i in range(srange[0], srange[1]+1): | ||||
|       indexes.add(i) | ||||
|   return indexes | ||||
		Reference in New Issue
	
	Block a user