onnxruntime/winml/lib/Api.Ort/OnnxruntimeEngineBuilder.h
Sheil Kumar 6255194659
All LearningModelSessions created from a common LearningModelDevice should share the same thread pool (#11457)
* Share thread pools between devices

* make tests reuse device

* Change cpu thread pool options for dml sessions to use 1 thread with no spinning

* fix test failure

* Update missing type constraints for dft

* Add comment and rename inference session parameter

* default missing causing inconsistent test behavior

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
2022-05-13 11:12:43 -07:00

56 lines
No EOL
1.7 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "iengine.h"
namespace _winml {
class OnnxruntimeEngineBuilder : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IEngineBuilder> {
public:
HRESULT RuntimeClassInitialize(_In_ OnnxruntimeEngineFactory* engine);
STDMETHOD(SetD3D12Resources)
(ID3D12Device* device, ID3D12CommandQueue* queue);
STDMETHOD(SetMetacommandsEnabled)
(int enabled);
STDMETHOD(GetD3D12Device)
(_Outptr_ ID3D12Device** device);
STDMETHOD(GetID3D12CommandQueue)
(_Outptr_ ID3D12CommandQueue** queue);
STDMETHOD(SetBatchSizeOverride)
(uint32_t batch_size_override);
STDMETHOD(SetNamedDimensionOverrides)
(wfc::IMapView<winrt::hstring, uint32_t> named_dimension_overrides);
STDMETHOD(SetIntraOpNumThreadsOverride)
(uint32_t intra_op_num_threads);
STDMETHOD(SetIntraOpThreadSpinning)
(bool allow_spinning);
STDMETHOD(SetThreadPool)
(IThreading* thread_pool);
STDMETHOD(CreateEngine)
(_Outptr_ IEngine** out);
private:
Microsoft::WRL::ComPtr<OnnxruntimeEngineFactory> engine_factory_;
Microsoft::WRL::ComPtr<ID3D12Device> device_ = nullptr;
Microsoft::WRL::ComPtr<ID3D12CommandQueue> queue_ = nullptr;
Microsoft::WRL::ComPtr<IThreading> thread_pool_ = nullptr;
bool metacommands_enabled_ = true;
std::optional<uint32_t> batch_size_override_;
wfc::IMapView<winrt::hstring, uint32_t> named_dimension_overrides_;
std::optional<uint32_t> intra_op_num_threads_override_;
bool allow_thread_spinning_ = true;
};
} // namespace _winml