onnxruntime/winml/lib/Api/LearningModelDevice.h
Sheil Kumar 2717c178cc
Fork the WinML APIs into the Microsoft namespace (#3503)
* Migrate winml to Microsoft Namespace (packaging changes are pending)

* add ns_prefix toggle

* fix packaging

* Users/sheilk/add missing raw header (#3484)

* add dualapipartition

* wrong variable for repo root

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>

* remove existence check to force failures

* extra paren

* dualapipartition needs to be referenced from the source

* add microsoft.ai.machinelearning.dll to the output dir

* rename the idl file so that assembly info is correctly added into the winmd

* fix namespaces

* update namespaces

* default to microsoft, and add namespace override as build argument

* update cmakesetings.json as well

* remove from cmakelists.txt

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
Co-authored-by: Changming Sun <chasun@microsoft.com>
2020-04-17 06:18:54 -07:00

99 lines
2.4 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "LearningModelDevice.g.h"
namespace _winml {
class ConverterResourceStore;
class D3DDeviceCache;
}
namespace WINMLP {
struct LearningModelDevice : LearningModelDeviceT<LearningModelDevice, IMetacommandsController, IDeviceFenceValidator> {
public:
LearningModelDevice() = delete;
LearningModelDevice(
winml::LearningModelDeviceKind const& deviceKind);
LearningModelDevice(
wgdx::Direct3D11::IDirect3DDevice const& device);
LearningModelDevice(
ID3D12CommandQueue* queue);
~LearningModelDevice();
wg::DisplayAdapterId
AdapterId();
static winml::LearningModelDevice CreateFromDirect3D11Device(
wgdx::Direct3D11::IDirect3DDevice const& device);
// internal:
STDMETHOD(SetMetacommandsEnabled)
(
boolean enabled) final;
// internal:
STDMETHOD_(boolean, SharedHandleInitialized)
();
// internal:
winml::LearningModelDeviceKind
GetDeviceKind();
bool
MetacommandsEnabled();
bool
IsCpuDevice();
const LUID&
GetDeviceLuid();
_winml::D3DDeviceCache*
GetD3DDeviceCache();
wgdx::Direct3D11::IDirect3DDevice
Direct3D11Device();
ID3D12Device*
GetD3DDevice();
ID3D12CommandQueue*
GetDeviceQueue();
static void
DllUnload();
std::shared_ptr<_winml::ConverterResourceStore>
TensorizerStore();
std::shared_ptr<_winml::ConverterResourceStore>
DetensorizerStore();
private:
// stores the device kind that was originally chosen in the constructor
winml::LearningModelDeviceKind m_deviceKind;
// if the user asked us to run on the cpu, or asked us to choose and we chose cpu
bool m_isCpuDevice;
bool m_areMetacommandsEnabled = true;
std::shared_ptr<_winml::ConverterResourceStore> m_detensorizerStore;
std::once_flag m_detensorizerStoreInitialized;
std::shared_ptr<_winml::ConverterResourceStore> m_tensorizerStore;
std::once_flag m_tensorizerStoreInitialized;
std::unique_ptr<_winml::D3DDeviceCache> m_deviceCache;
};
} // namespace WINMLP
namespace WINML::factory_implementation {
struct LearningModelDevice : LearningModelDeviceT<LearningModelDevice, implementation::LearningModelDevice, ILearningModelDeviceFactoryNative> {
HRESULT __stdcall CreateFromD3D12CommandQueue(ID3D12CommandQueue* queue, IUnknown** device) noexcept final;
};
} // namespace WINML::factory_implementation