onnxruntime/winml/lib/Api.Ort/OnnxruntimeModel.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

80 lines
No EOL
2.5 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once
#include "iengine.h"
namespace _winml {
class OnnxruntimeEngineFactory;
// The IOrtSessionBuilder offers an abstraction over the creation of
// InferenceSession, that enables the creation of the session based on a device (CPU/DML).
MIDL_INTERFACE("92679cbf-7a9d-48bb-b97f-ef9fb447ce8e")
IOnnxruntimeModel : IUnknown {
virtual HRESULT STDMETHODCALLTYPE DetachOrtModel(OrtModel * *model) PURE;
};
class ModelInfo : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IModelInfo> {
public:
HRESULT RuntimeClassInitialize(_In_ OnnxruntimeEngineFactory* engine, _In_ OrtModel* ort_model);
STDMETHOD(GetAuthor)
(const char** out, size_t* len);
STDMETHOD(GetName)
(const char** out, size_t* len);
STDMETHOD(GetDomain)
(const char** out, size_t* len);
STDMETHOD(GetDescription)
(const char** out, size_t* len);
STDMETHOD(GetVersion)
(int64_t* out);
STDMETHOD(GetModelMetadata)
(ABI::Windows::Foundation::Collections::IMapView<HSTRING, HSTRING>** metadata);
STDMETHOD(GetInputFeatures)
(ABI::Windows::Foundation::Collections::IVectorView<winml::ILearningModelFeatureDescriptor>** features);
STDMETHOD(GetOutputFeatures)
(ABI::Windows::Foundation::Collections::IVectorView<winml::ILearningModelFeatureDescriptor>** features);
private:
std::string author_;
std::string name_;
std::string domain_;
std::string description_;
int64_t version_;
std::unordered_map<std::string, std::string> model_metadata_;
wfc::IVector<winml::ILearningModelFeatureDescriptor> input_features_;
wfc::IVector<winml::ILearningModelFeatureDescriptor> output_features_;
};
class OnnruntimeModel : public Microsoft::WRL::RuntimeClass<
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
IModel,
IOnnxruntimeModel> {
public:
OnnruntimeModel();
HRESULT RuntimeClassInitialize(OnnxruntimeEngineFactory* engine, UniqueOrtModel&& ort_model);
STDMETHOD(GetModelInfo)
(IModelInfo** info);
STDMETHOD(ModelEnsureNoFloat16)
();
STDMETHOD(CloneModel)
(IModel** copy);
STDMETHOD(DetachOrtModel)
(OrtModel** model);
private:
UniqueOrtModel ort_model_;
Microsoft::WRL::ComPtr<OnnxruntimeEngineFactory> engine_factory_;
Microsoft::WRL::ComPtr<ModelInfo> info_;
std::optional<std::unordered_map<std::string, std::string>> metadata_cache_;
};
} // namespace _winml