Skip to content

Latest commit

 

History

History
51 lines (31 loc) · 1.27 KB

learningmodelsessionoptions_overridenameddimension_1820294804.md

File metadata and controls

51 lines (31 loc) · 1.27 KB
-api-id -api-type
M:Windows.AI.MachineLearning.LearningModelSessionOptions.OverrideNamedDimension(System.String,System.UInt32)
winrt method

Windows.AI.MachineLearning.LearningModelSessionOptions.OverrideNamedDimension(System.String,System.UInt32)

-description

Provides the ability to override named input dimensions of a Learning Model to concrete values.

-parameters

-param name

The name of the input dimension to set.

-param dimension

The concrete value to assign to the specified dimension.

-remarks

Using this API can yield performance improvements, as it allows for preallocation of tensors during session creation that would otherwise be allocated during model evaluation.

-see-also

NamedDimensionOverride interface

-examples

void SetNamedDimensionOverrides(LearningModel model) {
    // Create LearningModelSessionOptions
    auto options = LearningModelSessionOptions();
 
    // Override a named input dimension to a concrete value
    options->OverrideNamedDimension(L"dimension_name", 256);
 
    // Create session
    LearningModelSession session = nullptr;
    session = LearningModelSession(model, LearningModelDeviceKind::GPU, options);
}