onnxruntime/winml/adapter/abi_custom_registry_impl.cpp
sumitsays 43c45ddd66
Update DirectML EP changes from DmlDev as of 2021-06-07 (#7987)
* Merged PR 6093117: Fix test_DynamicQuantizedLinear_max_adjusted_expanded by allowing Identity operator to run on non-float inputs

Motivation:
As part of the OnnxConformance Backend tests, DynamicQuantizedLinear_max_adjusted_expanded is failing.

Root Cause:
- The test model has `Identity` operator as one of the node. The input of this node is of non-float data type.
- In DML, `Identity` operator is registered as operator which requires floating input.
- As per `DirectMLSchema.h`, support for non-float input has been added for `Identity` operator in DML but the same has not been reflected in the `OperatorRegistration.cpp`.

Changes:
- Removed all traces of the requiresFloatFormatsForGraph flag from it's definition and usage. This flag was only used for Identity and it's related operator.
- Added null check for the graphOutput nodeArg in GraphDescBuilder.cpp to stop the crash of the test.

Related work items: #33076298

* Merged PR 6103324: Remove usage of non-generic error code (FWP_E_NULL_POINTER)

Motivation:
Addressing Dwayne comment on the previous PR. [Ref: [6093117](https://dev.azure.com/microsoft/WindowsAI/_git/onnxruntime/pullrequest/6093117?discussionId=44292162&path=%2Fonnxruntime%2Fcore%2Fproviders%2Fdml%2FDmlExecutionProvider%2Fsrc%2FGraphPartitioner.cpp)]

Changes:
Inside the DML EP, we should not use some other platform specific error codes. Instead we should a appropriate generic error code.

Related work items: #33076298

Co-authored-by: Sumit Agarwal <sumitagarwal@microsoft.com>
2021-06-11 11:09:48 -07:00

93 lines
3 KiB
C++

// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include "pch.h"
#ifdef USE_DML
#include "abi_custom_registry_impl.h"
namespace Windows::AI::MachineLearning::Adapter {
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorSetSchema(
const MLOperatorSetId* opSetId,
int baseline_version,
const MLOperatorSchemaDescription* const* schema,
uint32_t schemaCount,
_In_opt_ IMLOperatorTypeInferrer* typeInferrer,
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer) const noexcept try {
#ifdef LAYERING_DONE
for (uint32_t i = 0; i < schemaCount; ++i) {
telemetry_helper.RegisterOperatorSetSchema(
schema[i]->name,
schema[i]->inputCount,
schema[i]->outputCount,
schema[i]->typeConstraintCount,
schema[i]->attributeCount,
schema[i]->defaultAttributeCount);
}
#endif
// Delegate to base class
return AbiCustomRegistry::RegisterOperatorSetSchema(
opSetId,
baseline_version,
schema,
schemaCount,
typeInferrer,
shapeInferrer);
}
CATCH_RETURN();
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorKernel(
const MLOperatorKernelDescription* opKernel,
IMLOperatorKernelFactory* operatorKernelFactory,
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer) const noexcept {
return RegisterOperatorKernel(opKernel, operatorKernelFactory, shapeInferrer, nullptr, false, false, false);
}
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorKernel(
const MLOperatorKernelDescription* opKernel,
IMLOperatorKernelFactory* operatorKernelFactory,
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer,
_In_opt_ IMLOperatorSupportQueryPrivate* supportQuery,
bool isInternalOperator,
bool canAliasFirstInput,
bool supportsGraph,
const uint32_t* requiredInputCountForGraph,
bool supportedWith64BitTensorsVia32BitStrides,
bool supportedWith64BitTensorsVia32BitStridesFromAnyEp,
bool prefer64BitTensorsDirectly,
_In_reads_(constantCpuInputCount) const uint32_t* requiredConstantCpuInputs,
uint32_t constantCpuInputCount) const noexcept try {
#ifdef LAYERING_DONE
// Log a custom op telemetry if the operator is not a built-in DML operator
if (!isInternalOperator) {
telemetry_helper.LogRegisterOperatorKernel(
opKernel->name,
opKernel->domain,
static_cast<int>(opKernel->executionType));
}
#endif
// Delegate to base class
return AbiCustomRegistry::RegisterOperatorKernel(
opKernel,
operatorKernelFactory,
shapeInferrer,
supportQuery,
isInternalOperator,
canAliasFirstInput,
supportsGraph,
requiredInputCountForGraph,
supportedWith64BitTensorsVia32BitStrides,
supportedWith64BitTensorsVia32BitStridesFromAnyEp,
prefer64BitTensorsDirectly,
requiredConstantCpuInputs,
constantCpuInputCount);
}
CATCH_RETURN();
} // namespace Windows::AI::MachineLearning::Adapter
#endif USE_DML