Skip to content

Conversation

@askhade
Copy link
Contributor

@askhade askhade commented Jan 24, 2022

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

  • Why is this change required? What problem does it solve?
  • If it fixes an open issue, please link to the issue here.

bool operator()(const Node* n1, const Node* n2) const;
};

enum class DataLayout {
Copy link
Contributor

@edgchen1 edgchen1 Feb 4, 2022

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()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetNodesInTopologicalOrder

just curious about this change - I believe any ordering is fine here as this function will do its own topological sort

Copy link
Contributor Author

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...

@askhade askhade changed the title [WIP] Add layout transformer for NNAPI Add layout transformer for NNAPI Feb 6, 2022
// 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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rank == 0

the comment above says "Rank must be >= 1."

Copy link
Contributor Author

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

// 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onnx_ops_available_versions

can 1 and 3 be unified?

Copy link
Contributor Author

@askhade askhade Feb 9, 2022

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
Copy link
Contributor

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
skottmckay previously approved these changes Feb 15, 2022
Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@askhade askhade merged commit f436d34 into master Feb 16, 2022
@askhade askhade deleted the askhade/layout_transformations branch February 16, 2022 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants