Parse user's devices input str to standard format. e.g. [gpu0, gpu1, ...]
(input_devices)
| 178 | |
| 179 | |
| 180 | def parse_devices(input_devices): |
| 181 | |
| 182 | """Parse user's devices input str to standard format. |
| 183 | e.g. [gpu0, gpu1, ...] |
| 184 | |
| 185 | """ |
| 186 | ret = [] |
| 187 | for d in input_devices.split(','): |
| 188 | for regex, func in REGEX: |
| 189 | m = regex.match(d.lower().strip()) |
| 190 | if m: |
| 191 | tmp = func(m.groups()) |
| 192 | # prevent duplicate |
| 193 | for x in tmp: |
| 194 | if x not in ret: |
| 195 | ret.append(x) |
| 196 | break |
| 197 | else: |
| 198 | raise NotSupportedCliException( |
| 199 | 'Can not recognize device: "{}"'.format(d)) |
| 200 | return ret |
nothing calls this directly
no test coverage detected