-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update kernel matching logic: decouple from op schemas and remove kernel def hashes #12791
Conversation
…lasses and fix usages.
This pull request introduces 1 alert and fixes 1 when merging da5c9f4 into 739b567 - view on LGTM.com new alerts:
fixed alerts:
|
This pull request introduces 6 alerts and fixes 1 when merging 716b756 into b935524 - view on LGTM.com new alerts:
fixed alerts:
|
onnxruntime/core/optimizer/selectors_actions/selector_action_transformer.cc
Show resolved
Hide resolved
@@ -593,7 +593,7 @@ static void CustomKernelWithCustomSchema() { | |||
floatTensorEdgeDesc.edgeType = MLOperatorEdgeType::Tensor; | |||
floatTensorEdgeDesc.tensorDataType = MLOperatorTensorDataType::Float; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Looks like a custom op WinML test. @smk2007? Seems okay 🤷♂️ (T to T1 makes sense, given the definition above), but I'm content if the test passes.
@@ -790,8 +790,6 @@ class ONNX_OPERATOR_KERNEL_CLASS_NAME(kCpuExecutionProvider, kOnnxDomain, 17, ST | |||
// !!PLEASE READ BELOW!! Following that, add new entries above this comment | |||
|
|||
/* *** IMPORTANT! *** | |||
If kernel registrations are incorrectly updated, ORT format models get broken as the kernel hashes may be invalidated. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@skottmckay should this be replaced another comment? I think it's still important to correctly register kernels
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would they register it correctly if the kernel def builder no longer generates a hash?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to yaml files LGTM. Sorry I didn't look into the other files.
This pull request introduces 1 alert and fixes 1 when merging 396a957 into b48f71f - view on LGTM.com new alerts:
fixed alerts:
|
/azp run orttraining-linux-gpu-ci-pipeline |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run Linux Eager Mode CI Pipeline |
Azure Pipelines successfully started running 1 pipeline(s). |
…nel def hashes (#12791) # Motivation Currently, ORT minimal builds use kernel def hashes to map from nodes to kernels to execute when loading the model. As the kernel def hashes must be known ahead of time, this works for statically registered kernels. This works well for the CPU EP. For this approach to work, the kernel def hashes must also be known at ORT format model conversion time, which means the EP with statically registered kernels must also be enabled then. This is not an issue for the always-available CPU EP. However, we do not want to require that any EP which statically registers kernels is always available too. Consequently, we explore another approach to match nodes to kernels that does not rely on kernel def hashes. An added benefit of this is the possibility of moving away from kernel def hashes completely, which would eliminate the maintenance burden of keeping the hashes stable. # Approach In a full build, ORT uses some information from the ONNX op schema to match a node to a kernel. We want to avoid including the ONNX op schema in a minimal build to reduce binary size. Essentially, we take the necessary information from the ONNX op schema and make it available in a minimal build. We decouple the ONNX op schema from the kernel matching logic. The kernel matching logic instead relies on per-op information which can either be obtained from the ONNX op schema or another source. This per-op information must be available in a minimal build when there are no ONNX op schemas. We put it in the ORT format model. Existing uses of kernel def hashes to look up kernels are replaced with the updated kernel matching logic. We no longer store kernel def hashes in the ORT format model’s session state and runtime optimization representations. We no longer keep the logic to generate and ensure stability of kernel def hashes.
…nel def hashes (microsoft#12791) # Motivation Currently, ORT minimal builds use kernel def hashes to map from nodes to kernels to execute when loading the model. As the kernel def hashes must be known ahead of time, this works for statically registered kernels. This works well for the CPU EP. For this approach to work, the kernel def hashes must also be known at ORT format model conversion time, which means the EP with statically registered kernels must also be enabled then. This is not an issue for the always-available CPU EP. However, we do not want to require that any EP which statically registers kernels is always available too. Consequently, we explore another approach to match nodes to kernels that does not rely on kernel def hashes. An added benefit of this is the possibility of moving away from kernel def hashes completely, which would eliminate the maintenance burden of keeping the hashes stable. # Approach In a full build, ORT uses some information from the ONNX op schema to match a node to a kernel. We want to avoid including the ONNX op schema in a minimal build to reduce binary size. Essentially, we take the necessary information from the ONNX op schema and make it available in a minimal build. We decouple the ONNX op schema from the kernel matching logic. The kernel matching logic instead relies on per-op information which can either be obtained from the ONNX op schema or another source. This per-op information must be available in a minimal build when there are no ONNX op schemas. We put it in the ORT format model. Existing uses of kernel def hashes to look up kernels are replaced with the updated kernel matching logic. We no longer store kernel def hashes in the ORT format model’s session state and runtime optimization representations. We no longer keep the logic to generate and ensure stability of kernel def hashes.
Motivation
Currently, ORT minimal builds use kernel def hashes to map from nodes to kernels to execute when loading the model. As the kernel def hashes must be known ahead of time, this works for statically registered kernels. This works well for the CPU EP.
For this approach to work, the kernel def hashes must also be known at ORT format model conversion time, which means the EP with statically registered kernels must also be enabled then. This is not an issue for the always-available CPU EP. However, we do not want to require that any EP which statically registers kernels is always available too.
Consequently, we explore another approach to match nodes to kernels that does not rely on kernel def hashes. An added benefit of this is the possibility of moving away from kernel def hashes completely, which would eliminate the maintenance burden of keeping the hashes stable.
Approach
In a full build, ORT uses some information from the ONNX op schema to match a node to a kernel. We want to avoid including the ONNX op schema in a minimal build to reduce binary size. Essentially, we will take the necessary information from the ONNX op schema and make it available in a minimal build.
We will decouple the ONNX op schema from the kernel matching logic. The kernel matching logic will instead rely on per-op information which can either be obtained from the ONNX op schema or another source.
This per-op information must be available in a minimal build when there are no ONNX op schemas. We can put it in the ORT format model.
Existing uses of kernel def hashes to look up kernels can be replaced with the updated kernel matching logic. We no longer need to store kernel def hashes in the ORT format model’s session state and runtime optimization representations. We no longer need to keep the logic to generate and ensure stability of kernel def hashes.