default_utils module

class default_utils.ArgumentStruct(**entries)[source]

Bases: object

Class that converts a python dictionary into an object with named entries given by the dictionary keys. This structure simplifies the calling convention for accessing the dictionary values (corresponding to problem parameters). After the object instantiation both modes of access (dictionary or object entries) can be used.

class default_utils.Benchmark(filepath, defmodel, framework, prog=None, desc=None, parser=None)[source]

Bases: object

Class that implements an interface to handle configuration options for the different CANDLE benchmarks. It provides access to all the common configuration options and configuration options particular to each individual benchmark. It describes what minimum requirements should be specified to instantiate the corresponding benchmark. It interacts with the argparser to extract command-line options and arguments from the benchmark’s configuration files.

check_required_exists(gparam)[source]

Functionality to verify that the required model parameters have been specified.

format_benchmark_config_arguments(dictfileparam)[source]

Functionality to format the particular parameters of the benchmark.

Parameters
  • dictfileparam (python dictionary) – parameters read from configuration file

  • args (python dictionary) – parameters read from command-line Most of the time command-line overwrites configuration file except when the command-line is using default values and config file defines those values

parse_from_benchmark()[source]

Functionality to parse options specific specific for each benchmark.

parse_from_common()[source]

Functionality to parse options common for all benchmarks. This functionality is based on methods ‘get_default_neon_parser’ and ‘get_common_parser’ which are defined previously(above). If the order changes or they are moved, the calling has to be updated.

read_config_file(file)[source]

Functionality to read the configue file specific for each benchmark.

set_locals()[source]

Functionality to set variables specific for the benchmark - required: set of required parameters for the benchmark. - additional_definitions: list of dictionaries describing the additional parameters for the benchmark.

class default_utils.ListOfListsAction(option_strings, dest, type, **kwargs)[source]

Bases: argparse.Action

This class extends the argparse.Action class by instantiating an argparser that constructs a list-of-lists from an input (command-line option or argument) given as a string.

default_utils.args_overwrite_config(args, config)[source]

Overwrite configuration parameters with parameters specified via command-line.

Parameters
  • args (ArgumentParser object) – Parameters specified via command-line

  • config (python dictionary) – Parameters read from configuration file

default_utils.check_file_parameters_exists(params_parser, params_benchmark, params_file)[source]

Functionality to verify that the parameters defined in the configuraion file are recognizable by the command line parser (i.e. no uknown keywords are used in the configuration file).

Parameters
  • params_parser (python dictionary) – Includes parameters set via the command line.

  • params_benchmark (python list) – Includes additional parameters defined in the benchmark.

  • params_file (python dictionary) –

    Includes parameters read from the configuration file.

    Global: PARAMETERS_CANDLE : python list

    Includes all the core keywords that are specified in CANDLE.

default_utils.check_flag_conflicts(params)[source]
default_utils.directory_from_parameters(params, commonroot='Output')[source]

Construct output directory path with unique IDs from parameters

Parameters
  • params (python dictionary) – Dictionary of parameters read

  • commonroot (string) – String to specify the common folder to store results.

default_utils.finalize_parameters(bmk)[source]

Utility to parse parameters in common as well as parameters particular to each benchmark.

Parameters

bmk (benchmark object) – Object that has benchmark filepaths and specifications

Returns

gParameters (python dictionary) – Dictionary with all the parameters necessary to run the benchmark. Command line overwrites config file specifications

default_utils.get_choice(name)[source]

Maps name string to the right type of argument

default_utils.get_common_parser(parser)[source]

Parse command-line arguments. Ignore if not present.

Parameters

parser (ArgumentParser object) – Parser for command-line options

default_utils.get_default_neon_parser(parser)[source]

Parse command-line arguments that are default in neon parser (and are common to all frameworks). Ignore if not present.

Parameters

parser (ArgumentParser object) – Parser for neon default command-line options

default_utils.keras_default_config()[source]

Defines parameters that intervine in different functions using the keras defaults. This helps to keep consistency in parameters between frameworks.

default_utils.set_seed(seed)[source]

Set the seed of the pseudo-random generator to the specified value.

Parameters

seed (int) – Value to intialize or re-seed the generator.