def select_workloads(argv): # type: (Iterable[str]) -> Iterable[(str, TBatchSize)] """Select workloads based on commandline Example: alexnet,vgg11 """ if not argv: names = WTL.known_workloads.keys() else: names = unique(( name for piece in argv for name in piece.split(',') ), stable=True) def getbs(name): if '_' in name: name, bs = name.split('_') bs = int(bs) return [(name, bs)] else: bss = WTL.from_name(name).available_batch_sizes() names = [name] * len(bss) return zip(names, bss) # TODO: return directly WTL instances return [(n, batch_size) for name in names for n, batch_size in getbs(name)]
def gen_workload_list(selection): # type: (str) -> Iterable[Tuple[WTL, RunConfig]] """Select workloads based on commandline""" if not selection: blacklist = ['speech', 'seq2seq', 'mnistlg', 'mnistsf', 'mnistcv'] names = ( (v, bs) for k, v in WTL.known_workloads.items() for bs in v.available_batch_sizes() if k not in blacklist ) else: names = [] for cname in unique((cname for cname in selection.split(',')), stable=True): if '_' not in cname: raise UsageError(f"Not a canonical name: {cname}") name, bs = cname.split('_', 1) bs = try_with_default(int, bs, ValueError)(bs) names.append((WTL.from_name(name), bs)) # Find all available batch_num with JCT and mem data return ( (wtl, RunConfig(bs, bn, None)) for wtl, bs in names for bn in wtl.available_batch_nums(bs) )
def select_workloads(argv): # type: (Iterable[str]) -> Iterable[(str, TBatchSize)] """Select workloads based on commandline Example: alexnet,vgg11 """ if not argv: names = [name for name in WTL.known_workloads.keys() if not name.endswith('eval')] else: names = unique(( name for piece in argv for name in piece.split(',') ), stable=True) def getbs(name): if '_' in name: name, bs = name.split('_') bs = int(bs) return [(name, bs)] else: # using a single batch size is enough bss = WTL.from_name(name).available_batch_sizes() return [(name, list(bss)[0])] # TODO: return directly WTL instances return [(n, batch_size) for name in names for n, batch_size in getbs(name)]
def select_workloads(argv): # type: (Iterable[str]) -> Iterable[(str, TBatchSize)] """Select workloads based on commandline""" if not argv: names = WTL.known_workloads.keys() else: names = unique(( name for piece in argv for name in piece.split(',') ), stable=True) # TODO: return directly WTL instances return [(name, batch_size) for name in names for batch_size in WTL.from_name(name).available_batch_sizes()]
def select_workloads(argv, # type: Iterable[str] batch_size=None, # type: Optional[Union[Iterable[TBatchSize], TBatchSize]] batch_num=None, # type: Optional[Union[Iterable[int], int]] executor=None # type: Optional[Union[Iterable[Executor], Executor]] ): # type: (...) -> Iterable[Workload] """Select workloads based on commandline Workloads can be separated by comma (',') or space (' '). The workload name can include a undersocre ('_') separated batch size. If no batch size part is included, batch sizes given in argument are selected. If argv is empty, all available workloads are selected. batch_size, batch_num, executor arguments expects a list of possible values, single value are converted into list. Returns: list of created Workload instance Example: alexnet_25,vgg11 inception3_75 """ if batch_size is not None: if not isinstance(batch_size, list): batch_size = [batch_size] if batch_num is None: batch_num = [1] else: if not isinstance(batch_num, list): batch_num = [batch_num] if executor is None: executor = [Executor.Salus] else: if not isinstance(executor, list): executor = [executor] if not argv: names = WTL.known_workloads.keys() else: names = unique(( name for piece in argv for name in piece.split(',') ), stable=True) def expandbs(name): if '_' in name: name, bs = name.split('_') return [(name, int(bs))] else: avail = WTL.from_name(name).available_batch_sizes() if batch_size is None: bss = avail else: bss = [bs for bs in batch_size if bs in avail] return zip([name] * len(bss), bss) wls = [name_bs for name in names for name_bs in expandbs(name)] wls = itertools.product(wls, batch_num, executor) return [WTL.create(name, bs, bn, ex) for (name, bs), bn, ex in wls]