-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)
Provides the ability to override named input dimensions of a Learning Model to concrete values.
The name of the input dimension to set.
The concrete value to assign to the specified dimension.
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.
NamedDimensionOverride interface
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);
}