-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add layout transformer for NNAPI #10371
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
Conversation
onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc
Outdated
Show resolved
Hide resolved
onnxruntime/core/providers/nnapi/nnapi_builtin/builders/op_builder.cc
Outdated
Show resolved
Hide resolved
| bool operator()(const Node* n1, const Node* n2) const; | ||
| }; | ||
|
|
||
| enum class DataLayout { |
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.
why is DataLayout defined in graph_viewer.h?
maybe move it to its own file so it can easily be included where needed?
|
|
||
| // initialize in-degrees and find root nodes | ||
| for (const auto& node : graph_viewer.Nodes()) { | ||
| for (const auto& node_index : graph_viewer.GetNodesInTopologicalOrder()) { |
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.
Changed it back ... I added it when I was debugging an old issue...
| // Computes permutation from channel last to channel first ordering of given rank. Nearly all handlers work for any | ||
| // permutation, but some are restricted. Also used for layout transformation. Rank must be >= 1. | ||
| std::vector<int64_t> ChannelLastToFirstPerm(size_t rank) { | ||
| if (rank == 0) { |
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.
api.h says rank must be >=2... updated the condition
onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc
Outdated
Show resolved
Hide resolved
| // Please update the following 3 places: | ||
| // 1. api_impl.cc "onnx_ops_available_versions" map, include the latest version in the map | ||
| // 2. kernel_registry_manager.cc "static_kernel_hashes" include an entry for latest version and it's associated hash | ||
| // 3. This file "onnx_ops_available_versions" map, include the latest version in the map |
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.
I thought of it... From this test perspective exposing this map via a Get mtd makes sense, however since the usage of this map is internal to api::AddNode I did not take that route.
| * @return std::optional<HashValue> | ||
| */ | ||
| std::optional<HashValue> GetHashValueFromStaticKernelHashMap(const std::string& op_type, int since_version); | ||
| } No newline at end of file |
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.
nit: can we make the relationship between the transpose optimizer a little clearer as standalone 'static kernel def hashes map' in the framework library is very general. maybe putting it in the onnxruntime::transpose_optimizer namespace would help.
'sesison state' -> 'session state'
skottmckay
left a comment
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
left a comment
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.
![]()
Description: Adding layout transformer which leverages the transpose optimizer for NCHW -> NHWC layout conversions for compile-based EPs. In the first phase converting NNAPI to use this.
Motivation and Context