IntraopNumThreads インターフェイス

LearningModelSessionOptions を使用して、CPU 演算子の Intra Operator Execution に対してスレッドプールで使用されるスレッドの数を変更する機能が提供されます。 既定では、WinML はスレッド最大数として値を設定します。この値は、ユーザーの CPU 上の論理コアと同じ数です。 この値を CPU 上の論理コア数より大きく設定すると、非効率的なスレッドプールが発生し、評価が遅くなる可能性があります。

サンプル コード

void SetIntraOpNumThreads(LearningModel model) {
    // Create LearningModelSessionOptions
    auto options = LearningModelSessionOptions();
    auto nativeOptions = options.as<ILearningModelSessionOptionsNative>();
 
    // Set the number of intra op threads to half of logical cores.
    uint32_t desiredThreads = std::thread::hardware_concurrency() / 2;
    nativeOptions->SetIntraOpNumThreadsOverride(desiredThreads);
 
    // Create session
    LearningModelSession session = nullptr;
    WINML_EXPECT_NO_THROW(session = LearningModelSession(model, LearningModelDeviceKind::Cpu, options));
}

要件

要件
サポートされている最小のクライアント Windows 10、ビルド 17763
サポートされている最小のサーバー デスクトップ エクスペリエンス搭載 Windows Server 2019
ヘッダー windows.ai.machinelearning.native.h

Note

Windows ML に関するヘルプについては、次のリソースを参照してください。

  • Windows ML に関する技術的な質問をしたり、質問に回答したりするには、Stack Overflowwindows-machine-learning タグを使用してください。
  • バグを報告するには、GitHub で問題を提出してください。