onnxruntime/winml/adapter/winml_adapter_c_api.cpp
Sheil Kumar 3d0bd2596f
Enable creating OrtValues from ID3D12Resources from the onnxruntime C-API (#9686)
* Add onnxruntime-windows api.

* minor fixes

* add to package headers

* Build ort_dml_api for provider extensions.

* Cleanup

* misc comment

* remove winml specific comments

* use dml check in onnxruntime

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/session/onnxruntime_c_api.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update onnxruntime/core/session/onnxruntime_c_api.cc

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update onnxruntime/core/session/ort_apis.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update winml/test/adapter/AdapterSessionTest.cpp

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update onnxruntime/core/session/onnxruntime_c_api.cc

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update winml/adapter/winml_adapter_c_api.cpp

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/session/onnxruntime_c_api.h

Co-authored-by: Pranav Sharma <prs@microsoft.com>

* Update onnxruntime/core/session/onnxruntime_c_api.cc

Co-authored-by: Pranav Sharma <prs@microsoft.com>

* Update winml/adapter/winml_adapter_c_api.cpp

* PR feedback

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* Update include/onnxruntime/core/providers/dml/dml_provider_factory.h

Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>

* PR feedback

* merge resolution and unreference param

* (naming) Remove Dml prefix

* maybe unused version

* move DML code into DML path. CIs failing because DML is not available when --use_dml is not on

* fix warning causing local build failures after merging

* Change getvaluememoryinfo to gettensormemoryinfo

* minor breaks

* fix comment paste

* fix comment

Co-authored-by: Sheil Kumar <sheilk@microsoft.com>
Co-authored-by: Dwayne Robinson <dwayner@microsoft.com>
Co-authored-by: Pranav Sharma <prs@microsoft.com>
2021-11-13 03:34:54 -08:00

105 lines
No EOL
3.1 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "adapter/pch.h"
#include "winml_adapter_c_api.h"
#include "winml_adapter_apis.h"
#include "core/session/ort_apis.h"
#include <core/providers/winml/winml_provider_factory.h>
#include <core/providers/cpu/cpu_provider_factory.h>
const OrtApi* GetVersion1Api();
namespace winmla = Windows::AI::MachineLearning::Adapter;
static constexpr WinmlAdapterApi winml_adapter_api_1 = {
// Schema override
&winmla::OverrideSchema,
// OrtEnv methods
&winmla::EnvConfigureCustomLoggerAndProfiler,
// OrtModel methods
&winmla::CreateModelFromPath,
&winmla::CreateModelFromData,
&winmla::CloneModel,
&winmla::ModelGetAuthor,
&winmla::ModelGetName,
&winmla::ModelGetDomain,
&winmla::ModelGetDescription,
&winmla::ModelGetVersion,
&winmla::ModelGetInputCount,
&winmla::ModelGetOutputCount,
&winmla::ModelGetInputName,
&winmla::ModelGetOutputName,
&winmla::ModelGetInputDescription,
&winmla::ModelGetOutputDescription,
&winmla::ModelGetInputTypeInfo,
&winmla::ModelGetOutputTypeInfo,
&winmla::ModelGetMetadataCount,
&winmla::ModelGetMetadata,
&winmla::ModelEnsureNoFloat16,
&winmla::SaveModel,
// OrtSessionOptions methods
&OrtSessionOptionsAppendExecutionProvider_CPU,
&winmla::OrtSessionOptionsAppendExecutionProviderEx_DML,
// OrtSession methods
&winmla::CreateSessionWithoutModel,
&winmla::SessionGetExecutionProvider,
&winmla::SessionInitialize,
&winmla::SessionRegisterGraphTransformers,
&winmla::SessionRegisterCustomRegistry,
&winmla::SessionLoadAndPurloinModel,
&winmla::SessionStartProfiling,
&winmla::SessionEndProfiling,
&winmla::SessionCopyOneInputAcrossDevices,
&winmla::SessionGetNumberOfIntraOpThreads,
&winmla::SessionGetIntraOpThreadSpinning,
&winmla::SessionGetNamedDimensionsOverrides,
// Dml methods (TODO need to figure out how these need to move to session somehow...)
&winmla::DmlExecutionProviderSetDefaultRoundingMode,
&winmla::DmlExecutionProviderFlushContext,
&winmla::DmlExecutionProviderReleaseCompletedReferences,
&winmla::DmlCopyTensor,
&winmla::GetProviderMemoryInfo,
&winmla::GetProviderAllocator,
&winmla::FreeProviderAllocator,
&winmla::ExecutionProviderSync,
&winmla::CreateCustomRegistry,
&winmla::ValueGetDeviceId,
&winmla::SessionGetInputRequiredDeviceId,
&winmla::CreateTensorTypeInfo,
&winmla::CreateSequenceTypeInfo,
&winmla::CreateMapTypeInfo,
&winmla::CreateModel,
&winmla::ModelAddInput,
&winmla::ModelAddConstantInput,
&winmla::ModelAddOutput,
&winmla::ModelAddOperator,
&winmla::ModelGetOpsetVersion,
&winmla::OperatorGetNumInputs,
&winmla::OperatorGetInputName,
&winmla::OperatorGetNumOutputs,
&winmla::OperatorGetOutputName,
&winmla::JoinModels,
// Release
&winmla::ReleaseModel
};
const WinmlAdapterApi* ORT_API_CALL OrtGetWinMLAdapter(_In_ uint32_t ort_version) NO_EXCEPTION {
if (ort_version >= 2) {
return &winml_adapter_api_1;
}
return nullptr;
}