FreeTensor
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
freetensor::RandCtxImpl Class Reference

#include <rand_ctx.h>

Inheritance diagram for freetensor::RandCtxImpl:
Inheritance graph
[legend]
Collaboration diagram for freetensor::RandCtxImpl:
Collaboration graph
[legend]

Public Member Functions

void observeTrace (const Ref< RandTrace > &trace, double value, double stddev)
 
void setLearnFilter (const std::regex &toLearn)
 
void setLearn ()
 
void setInfer ()
 

Protected Attributes

std::unordered_map< ProgramPosition, std::unordered_map< Ref< RandCondInterface >, Ref< DiscreteRandVar >, PtrInvocable< std::hash< RandCondInterface > >, PtrInvocable< std::equal_to< RandCondInterface > > > > randVars_
 
std::unordered_map< ProgramPosition, Ref< std::vector< int > > > totCnt_
 
std::multimap< Ref< RandTrace >, std::pair< double, double >, PtrInvocable< std::less< RandTrace > > > traces_
 
bool isInfer_ = true
 
std::regex toLearn_ {".*"}
 
std::mutex lock_
 

Detailed Description

Non-template base class for RandCtx

Member Function Documentation

◆ observeTrace()

void freetensor::RandCtxImpl::observeTrace ( const Ref< RandTrace > &  trace,
double  value,
double  stddev 
)

Learn from a trace

This trace is compared with existing traces. For each two trace being compared, the first different decision will be found, whose random variable will be upadated to perfer the decision from the trace of the lower value

This function must be called from the master thread

◆ setInfer()

void freetensor::RandCtxImpl::setInfer ( )
inline

When decide later, pick a most likely decision

This function must be called from the master thread

◆ setLearn()

void freetensor::RandCtxImpl::setLearn ( )
inline

When decide later, randomly sample a decision

This function must be called from the master thread

◆ setLearnFilter()

void freetensor::RandCtxImpl::setLearnFilter ( const std::regex &  toLearn)
inline

Set to learn some of the random variables only

A pattern can be set, and then only the variables matching this pattern is set to learning. This is useful when testing some of the random decisions with few learning trials

This function must be called from the master thread

Member Data Documentation

◆ isInfer_

bool freetensor::RandCtxImpl::isInfer_ = true
protected

◆ lock_

std::mutex freetensor::RandCtxImpl::lock_
protected

◆ randVars_

std::unordered_map< ProgramPosition, std::unordered_map<Ref<RandCondInterface>, Ref<DiscreteRandVar>, PtrInvocable<std::hash<RandCondInterface> >, PtrInvocable<std::equal_to<RandCondInterface> > > > freetensor::RandCtxImpl::randVars_
protected

◆ toLearn_

std::regex freetensor::RandCtxImpl::toLearn_ {".*"}
protected

◆ totCnt_

std::unordered_map<ProgramPosition, Ref<std::vector<int> > > freetensor::RandCtxImpl::totCnt_
protected

◆ traces_

std::multimap<Ref<RandTrace>, std::pair<double, double>, PtrInvocable<std::less<RandTrace> > > freetensor::RandCtxImpl::traces_
protected

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