Tensor Comprehensions
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tc::autotune::GeneticSearch Class Reference

#include <genetic_search.h>

Collaboration diagram for tc::autotune::GeneticSearch:

Public Types

using Population = std::vector< std::unique_ptr< CandidateConfiguration >>
 

Public Member Functions

 GeneticSearch (const TuningConfiguration &conf, size_t n, uint8_t crossOverRate, uint8_t mutationRate, size_t numberElites)
 
 GeneticSearch (const std::vector< TuningConfiguration > &confs, size_t n, uint8_t crossOverRate, uint8_t mutationRate, size_t numberElites)
 
void updateParameters ()
 

Public Attributes

Population population
 
TuningConfiguration lastBestConf
 
const size_t kMaxPopulationSize
 
const uint8_t kCrossOverRate
 
const uint8_t kMutationRate
 
const size_t kNumberElites
 
std::mt19937_64 rng
 

Static Public Attributes

static constexpr int kMutateIterations = 1000
 
static constexpr int kMinCandidatesForBreeding = 3
 

Private Member Functions

void breed ()
 
TuningConfiguration crossover (TuningConfiguration &, TuningConfiguration &, TuningConfiguration &) const
 

Detailed Description

GeneticSearch operates on generations of candidate solutions. Each generation consists of multiple candidate solutions. Before a new generation can be generated all candidates of the current one are assigned a fitness value (1 / runtime (in us) in our case).

The top candidates are preserved intact across generation (elitism).

Each new candidate is generated with the following two mechanisms:

crossover: 3 parent candidates are selected probabilistically (influenced by their fitness, the higher it is the higher the chance of selection) and merged into a new candidate

mutation: parts of a candidate are randomly changed (mutated)

The crossover rate controls how many candidates survive across generations and how many new candidates are produced through crossover, e.g, 80% crossover rate would result in roughly 20% of the new generation to consist of candidates that survived from the previous one. Note, that this is different from elitism: elite candidates are not mutated but "survivors" are.

The mutation rate controls the probability with which mutation occurs.

Member Typedef Documentation

using tc::autotune::GeneticSearch::Population = std::vector<std::unique_ptr<CandidateConfiguration>>

Constructor & Destructor Documentation

tc::autotune::GeneticSearch::GeneticSearch ( const TuningConfiguration conf,
size_t  n,
uint8_t  crossOverRate,
uint8_t  mutationRate,
size_t  numberElites 
)

conf is used to determine which are the tunable parameters, the selected values in conf are ignored and the population is randomized

n is the population size

crossoverRate is the probability ([0,100]) that a new candidate is produced through reproduction

mutationRate is the probability ([0,100]) that parameters are mutated (randomly changed) whenever a new generation is created

numberElites best candidates are preserved across generations (elitism), number Elites must be less than n

tc::autotune::GeneticSearch::GeneticSearch ( const std::vector< TuningConfiguration > &  confs,
size_t  n,
uint8_t  crossOverRate,
uint8_t  mutationRate,
size_t  numberElites 
)

confs are used to seed the first generation, the rest of the population is randomly initialized

n is the population size

crossoverRate is the probability ([0,100]) that a new candidate is produced through reproduction

mutationRate is the probability ([0,100]) that parameters are mutated (randomly changed) whenever a new generation is created

numberElites best candidates are preserved across generations (elitism), number Elites must be less than n

Member Function Documentation

void tc::autotune::GeneticSearch::breed ( )
private
TuningConfiguration tc::autotune::GeneticSearch::crossover ( TuningConfiguration ,
TuningConfiguration ,
TuningConfiguration  
) const
private
void tc::autotune::GeneticSearch::updateParameters ( )

Member Data Documentation

const uint8_t tc::autotune::GeneticSearch::kCrossOverRate
const size_t tc::autotune::GeneticSearch::kMaxPopulationSize
constexpr int tc::autotune::GeneticSearch::kMinCandidatesForBreeding = 3
static
constexpr int tc::autotune::GeneticSearch::kMutateIterations = 1000
static
const uint8_t tc::autotune::GeneticSearch::kMutationRate
const size_t tc::autotune::GeneticSearch::kNumberElites
TuningConfiguration tc::autotune::GeneticSearch::lastBestConf
Population tc::autotune::GeneticSearch::population
std::mt19937_64 tc::autotune::GeneticSearch::rng
mutable

The documentation for this class was generated from the following file: