Class ModelCompiler
A model compiler takes a model specified in MSL and compiles it into the code
required to perform inference in that model, as specified by the inference engine settings
and model attributes.
Inheritance
ModelCompiler
Assembly: Microsoft.ML.Probabilistic.Compiler.dll
Syntax
public class ModelCompiler
Properties
If true, comments will be added to the generated code.
Declaration
public bool AddComments { get; set; }
Property Value
Algorithm
The inference algorithm to use.
Declaration
public IAlgorithm Algorithm { get; set; }
Property Value
AllowDerivedParents
If true, allow factor arguments marked 'stochastic' to be derived. This can cause inference to diverge on some models.
Declaration
public bool AllowDerivedParents { get; set; }
Property Value
AllowSerialInitialisers
Experimental feature: Allow Sequential loops in the initialisation schedule. Set this to false to work around scheduling problems.
Declaration
public bool AllowSerialInitialisers { get; set; }
Property Value
BrowserMode
Controls when the model compiler browser is shown
Declaration
public BrowserMode BrowserMode { get; set; }
Property Value
CatchExceptions
If true, compiler exceptions are caught and displayed in the transform browser, rather than propagating to the caller.
Declaration
public bool CatchExceptions { get; set; }
Property Value
CompilerChoice
Selects the used compiler: Roslyn or CodeDom.Compiler.
Declaration
public CompilerChoice CompilerChoice { get; set; }
Property Value
DeclarationProvider
Declaration provider for model defined in MSL
Declaration
public IDeclarationProvider DeclarationProvider { get; set; }
Property Value
EnforceTriggers
If false, trigger and fresh annotations will not be enforced during scheduling. Useful for debugging infinite RepairSchedule loops.
Declaration
public bool EnforceTriggers { get; set; }
Property Value
List of extra transforms to run before IterativeProcessTransform
Declaration
public IList<Func<ICodeTransform>> ExtraTransforms { get; set; }
Property Value
FreeMemory
Trade memory for time.
If true, memory usage is reduced for increase in time. Temporary storage will be freed when inference completes, requiring re-allocation every time inference is run.
If false, memory usage is increased for reduction in time. Temporary storage will be kept and re-used for later inference runs.
Declaration
public bool FreeMemory { get; set; }
Property Value
GeneratedSourceFolder
The path (absolute or relative) where source code files will be generated.
Declaration
public string GeneratedSourceFolder { get; set; }
Property Value
GenerateInMemory
Controls if inference assembly is generated in memory or on disk.
Declaration
public bool GenerateInMemory { get; set; }
Property Value
IgnoreEqualObservedValuesForReferenceTypes
Let's you control what happens when you set an observed value which is equal
to the old observed value (for reference types). If this property is true, setting an equal
value will be ignored. If false, setting an equal value may cause inference to be re-run.
Declaration
public bool IgnoreEqualObservedValuesForReferenceTypes { get; set; }
Property Value
IgnoreEqualObservedValuesForValueTypes
Let's you control what happens when you set an observed value which is equal
to the old observed value (for value types). If this property is true, setting an equal
value will be ignored. If false, setting an equal value may cause inference to be re-run.
Declaration
public bool IgnoreEqualObservedValuesForValueTypes { get; set; }
Property Value
Controls if debug information is included in generated DLLs. If true, debug information will
be included which allows stepping through the generated code in a debugger.
Declaration
public bool IncludeDebugInformation { get; set; }
Property Value
InitialisationAffectsSchedule
If true, user-provided initializations will affect the iteration schedule. This can sometimes improve the convergence rate.
Declaration
public bool InitialisationAffectsSchedule { get; set; }
Property Value
Logging
If true, a variable named "loggingAction" will be used to log method entry/exit.
Declaration
public bool Logging { get; set; }
Property Value
OptimiseInferenceCode
Optimises generated code by removing redundant messages or operations.
Declaration
public bool OptimiseInferenceCode { get; set; }
Property Value
PriorityList
A list of message operator containers, highest priority first.
Declaration
public IList<object> PriorityList { get; }
Property Value
RecommendedQuality
Sets the quality band at which is recommended for running inference. By default
this is QualityBand.Preview.
Declaration
public QualityBand RecommendedQuality { get; set; }
Property Value
RequiredQuality
Sets the component quality band which is required for running inference. By default
this is QualityBand.Experimental.
Declaration
public QualityBand RequiredQuality { get; set; }
Property Value
ReturnCopies
If true, code will be generated to return copies of the internal marginal distributions.
If this is not done, the returned marginals are volatile and may be modified in place when inference runs again.
Set to false to save memory/time.
Declaration
public bool ReturnCopies { get; set; }
Property Value
ShowProgress
If true, prints compilation progress information to the console during model compilation.
Declaration
public bool ShowProgress { get; set; }
Property Value
ShowSchedule
If true, displays the schedule for the model, after the scheduler has run.
Declaration
public bool ShowSchedule { get; set; }
Property Value
ShowWarnings
If true, compiler warnings are printed to the console.
Declaration
public bool ShowWarnings { get; set; }
Property Value
TraceAllMessages
If true, all variables will implicitly have a TraceMessages attribute.
Declaration
public bool TraceAllMessages { get; set; }
Property Value
TreatWarningsAsErrors
If true, compiler warnings are treated as errors.
Declaration
public bool TreatWarningsAsErrors { get; set; }
Property Value
UnrollLoops
If true, all loops with constant bounds will be unrolled.
Declaration
public bool UnrollLoops { get; set; }
Property Value
UseExistingSourceFiles
If true and WriteSourceFiles=true, existing source code files will be used instead of re-generated.
Declaration
public bool UseExistingSourceFiles { get; set; }
Property Value
UseExperimentalSerialSchedules
Declaration
public bool UseExperimentalSerialSchedules { get; set; }
Property Value
UseLocals
If true and OptimiseInferenceCode=true, then the generated code is optimized by converting array elements to loop locals where possible.
Declaration
public bool UseLocals { get; set; }
Property Value
UseParallelForLoops
If true, use Parallel.For() instead of top-level for loops in the generated code.
Requires the Microsoft Parallel Extensions to be installed.
Declaration
public bool UseParallelForLoops { get; set; }
Property Value
UseSerialSchedules
Find serial schedules for graphs with offset indexing.
Declaration
public bool UseSerialSchedules { get; set; }
Property Value
UseSpecialFirstIteration
Experimental feature: generate a schedule using InitializeTo for the first iteration and another schedule ignoring InitializeTo for the remaining iterations.
Declaration
public bool UseSpecialFirstIteration { get; set; }
Property Value
WriteSourceFiles
Controls if source code files are written to disk. If true, source code files will be
written out to the GeneratedSourceFolder.
Declaration
public bool WriteSourceFiles { get; set; }
Property Value
Methods
Compile(ModelCompiler.ModelDefinitionMethod)
Declaration
public IGeneratedAlgorithm Compile(ModelCompiler.ModelDefinitionMethod method)
Parameters
Returns
Compile<T1>(ModelCompiler.ModelDefinitionMethod<T1>)
Declaration
public IGeneratedAlgorithm Compile<T1>(ModelCompiler.ModelDefinitionMethod<T1> method)
Parameters
Returns
Type Parameters
Compile<T1>(ModelCompiler.ModelDefinitionMethod<T1>, T1)
Declaration
public IGeneratedAlgorithm Compile<T1>(ModelCompiler.ModelDefinitionMethod<T1> method, T1 arg1)
Parameters
Returns
Type Parameters
Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9, T10 arg10)
Parameters
Type |
Name |
Description |
ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> |
method |
|
T1 |
arg1 |
|
T2 |
arg2 |
|
T3 |
arg3 |
|
T4 |
arg4 |
|
T5 |
arg5 |
|
T6 |
arg6 |
|
T7 |
arg7 |
|
T8 |
arg8 |
|
T9 |
arg9 |
|
T10 |
arg10 |
|
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
T10 |
|
Compile<T1, T2>(ModelCompiler.ModelDefinitionMethod<T1, T2>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2>(ModelCompiler.ModelDefinitionMethod<T1, T2> method)
Parameters
Returns
Type Parameters
Compile<T1, T2>(ModelCompiler.ModelDefinitionMethod<T1, T2>, T1, T2)
Declaration
public IGeneratedAlgorithm Compile<T1, T2>(ModelCompiler.ModelDefinitionMethod<T1, T2> method, T1 arg1, T2 arg2)
Parameters
Returns
Type Parameters
Compile<T1, T2, T3>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
Compile<T1, T2, T3>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3>, T1, T2, T3)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3> method, T1 arg1, T2 arg2, T3 arg3)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
Compile<T1, T2, T3, T4>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
Compile<T1, T2, T3, T4>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4>, T1, T2, T3, T4)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
Compile<T1, T2, T3, T4, T5>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
Compile<T1, T2, T3, T4, T5>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5>, T1, T2, T3, T4, T5)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
Compile<T1, T2, T3, T4, T5, T6>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
Compile<T1, T2, T3, T4, T5, T6>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6>, T1, T2, T3, T4, T5, T6)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
Compile<T1, T2, T3, T4, T5, T6, T7>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
Compile<T1, T2, T3, T4, T5, T6, T7>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7>, T1, T2, T3, T4, T5, T6, T7)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
Compile<T1, T2, T3, T4, T5, T6, T7, T8>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
Compile<T1, T2, T3, T4, T5, T6, T7, T8>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8>, T1, T2, T3, T4, T5, T6, T7, T8)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9>)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9> method)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9>, T1, T2, T3, T4, T5, T6, T7, T8, T9)
Declaration
public IGeneratedAlgorithm Compile<T1, T2, T3, T4, T5, T6, T7, T8, T9>(ModelCompiler.ModelDefinitionMethod<T1, T2, T3, T4, T5, T6, T7, T8, T9> method, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9)
Parameters
Returns
Type Parameters
Name |
Description |
T1 |
|
T2 |
|
T3 |
|
T4 |
|
T5 |
|
T6 |
|
T7 |
|
T8 |
|
T9 |
|
CompileWithoutParams(MethodBase)
Compiles the model defined in MSL by the specified method. The model parameters are not
set - they must be set before the model is executed.
Declaration
public IGeneratedAlgorithm CompileWithoutParams(MethodBase method)
Parameters
Returns
Type |
Description |
IGeneratedAlgorithm |
An instance of the compiled model, without any parameters set.
|
CompileWithParamArray(MethodBase, Object[])
Compiles the model defined in MSL by the specified method. The model parameters are set
to the specified values. This method should only be used when the method has more than 10 parameters,
otherwise one of the strongly typed
Compile
methods should be used.
Declaration
public IGeneratedAlgorithm CompileWithParamArray(MethodBase method, params object[] varValues)
Parameters
Returns
Type |
Description |
IGeneratedAlgorithm |
An instance of the compiled model, with all parameters set.
|
GivePriorityTo(Object)
Resolve ambiguous matches for message operators in favor of the given container. Accumulates with all previous calls.
Declaration
public void GivePriorityTo(object container)
Parameters
Type |
Name |
Description |
Object |
container |
A Type, namespace string, Module, or Assembly.
|
OnParametersChanged()
Declaration
protected void OnParametersChanged()
RemovePriority(Object)
Remove any priority of container given by previous calls to GivePriorityTo.
Declaration
public void RemovePriority(object container)
Parameters
Type |
Name |
Description |
Object |
container |
|
SetTo(ModelCompiler)
Configures this model compiler by copying settings from the supplied model compiler.
Declaration
public void SetTo(ModelCompiler compiler)
Parameters
Type |
Name |
Description |
ModelCompiler |
compiler |
The compiler to copy settings from
|
Events
Compiled
Event raised after a model is compiled or fails to compile.
Declaration
public event ModelCompiler.CompileEventHandler Compiled
Event Type
Compiling
Event raised before a model is compiled.
Declaration
public event ModelCompiler.CompileEventHandler Compiling
Event Type
ParametersChanged
Event raised when a compilation parameter is changed.
Declaration
public event EventHandler ParametersChanged
Event Type