onnxruntime/winml/adapter/AbiCustomRegistryImpl.cpp

88 lines
2.6 KiB
C++
Raw Normal View History

2019-08-15 22:27:05 +00:00
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#include "pch.h"
#ifdef USE_DML
#include "AbiCustomRegistryImpl.h"
2019-08-15 22:27:05 +00:00
namespace Windows::AI::MachineLearning::Adapter {
2019-08-15 22:27:05 +00:00
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 {
2019-11-08 21:23:44 +00:00
#ifdef LAYERING_DONE
2019-08-15 22:27:05 +00:00
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);
}
2019-11-08 21:23:44 +00:00
#endif
2019-08-15 22:27:05 +00:00
// 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, false, false, false);
}
HRESULT STDMETHODCALLTYPE AbiCustomRegistryImpl::RegisterOperatorKernel(
const MLOperatorKernelDescription* opKernel,
IMLOperatorKernelFactory* operatorKernelFactory,
_In_opt_ IMLOperatorShapeInferrer* shapeInferrer,
bool isInternalOperator,
bool canAliasFirstInput,
bool supportsGraph,
const uint32_t* requiredInputCountForGraph,
bool requiresFloatFormatsForGraph,
_In_reads_(constantCpuInputCount) const uint32_t* requiredConstantCpuInputs,
uint32_t constantCpuInputCount) const noexcept try {
2019-11-08 21:23:44 +00:00
#ifdef LAYERING_DONE
2019-08-15 22:27:05 +00:00
// 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));
}
2019-11-08 21:23:44 +00:00
#endif
2019-08-15 22:27:05 +00:00
// Delegate to base class
return AbiCustomRegistry::RegisterOperatorKernel(
opKernel,
operatorKernelFactory,
shapeInferrer,
isInternalOperator,
canAliasFirstInput,
supportsGraph,
requiredInputCountForGraph,
requiresFloatFormatsForGraph,
requiredConstantCpuInputs,
constantCpuInputCount);
}
CATCH_RETURN();
} // namespace Windows::AI::MachineLearning::Adapter
#endif USE_DML