neural_compressor.experimental.nas.dynast.dynas_manager

DyNAS Manager class.

Module Contents

Classes

ParameterManager

The ParameterManager class.

TransformerLTEncoding

The ParameterManager class.

class neural_compressor.experimental.nas.dynast.dynas_manager.ParameterManager(param_dict: dict, verbose: bool = False, seed: int = 0)

The ParameterManager class.

It handles the super-network encoding representation and translates between the 1-hot predictor, pymoo, and super-network dictionary formats during search.

Parameters:

param_dict (dict) – the search space dictionary.

process_param_dict() Tuple[list, list, int]

Build a parameter mapping arrays and an upper-bound vector for pymoo.

onehot_generic(in_array: list) numpy.ndarray

Generate onehot vector.

This is a generic approach to one-hot vectorization for predictor training and testing. It does not account for unused parameter mapping (e.g. block depth). For unused parameter mapping, the end user will need to provide a custom solution.

Parameters:

input_array (list) – the pymoo individual 1-D vector

Returns:

the map for elastic parameters of the supernetwork

Return type:

mapper (numpy array)

random_sample() list

Generate a random subnetwork from the possible elastic parameter range.

random_samples(size: int = 100, trial_limit: int = 100000) List[list]

Generate a list of random subnetworks from the possible elastic parameter range.

translate2param(pymoo_vector: list) dict

Translate a PyMoo 1-D parameter vector back to the elastic parameter dictionary format.

translate2pymoo(parameters: dict) list

Translate a single parameter dict to pymoo vector.

import_csv(filepath: str, config: str, objective: str, column_names: List[str] = None, drop_duplicates: bool = True) pandas.DataFrame

Import a csv file.

Import a csv file generated from a supernetwork search for the purpose of training a predictor.

Parameters:
  • filepath (str) – path of the csv to be imported.

  • config (str) – the subnetwork configuration.

  • objective (str) – target/label for the subnet configuration (e.g. accuracy, latency).

  • column_names – a list of column names for the dataframe.

Returns:

the output dataframe that contains the original config dict, pymoo, and 1-hot

equivalent vector for training.

Return type:

df

set_seed(seed) None

Set the random seed for randomized subnet generation and test/train split.

static create_training_set(dataframe: pandas.DataFrame, train_with_all: bool = True, split: float = 0.33, seed: bool = None) Tuple[list, list, list, list]

Create the training set.

Create a sklearn compatible test/train set from an imported results csv after “import_csv” method is run.

class neural_compressor.experimental.nas.dynast.dynas_manager.TransformerLTEncoding(param_dict: dict, verbose: bool = False, seed: int = 0)

Bases: ParameterManager

The ParameterManager class.

It handles the super-network encoding representation and translates between the 1-hot predictor, pymoo, and super-network dictionary formats during search.

Parameters:

param_dict (dict) – the search space dictionary.

import_csv(filepath: str, config: str, objective: str, column_names: List[str] = None, drop_duplicates: bool = True) pandas.DataFrame

Import a csv file generated from a supernetwork search for the purpose of training a predictor.

filepath - path of the csv to be imported. config - the subnetwork configuration objective - target/label for the subnet configuration (e.g. accuracy, latency) column_names - a list of column names for the dataframe df - the output dataframe that contains the original config dict, pymoo, and 1-hot

equivalent vector for training.

create_training_set(dataframe: pandas.DataFrame, train_with_all: bool = True, split: float = 0.33, seed: bool = None) Tuple[list, list, list, list]

Create a sklearn compatible test/train.

The set is created from an imported results csv after “import_csv” method is run.