examples: switch to nhwc#8
Open
vgvozdeva wants to merge 15 commits into
Open
Conversation
482c9b2 to
23d2f48
Compare
Owner
Author
|
make test |
Owner
Author
|
make test |
There was a problem hiding this comment.
Pull request overview
This PR updates oneDNN example code to use NHWC as the user-facing plain (non-blocked) layout instead of NCHW, aligning examples and accompanying tutorial text around NHWC across C, C++, SYCL, and OpenCL interop samples.
Changes:
- Switched example memory descriptors from
nchw/dnnl_nchwtonhwc/dnnl_nhwcacross many examples. - Updated tutorial/documentation text in several examples to reference NHWC.
- Adjusted C example tensor initialization indexing to match NHWC physical layout.
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/sycl_interop_usm.cpp | Switches SYCL USM interop example tensor layout to NHWC. |
| examples/sycl_interop_buffer.cpp | Switches SYCL buffer interop example tensor layout + comment to NHWC. |
| examples/primitives/sum.cpp | Uses NHWC for source memory descriptors in sum example. |
| examples/primitives/shuffle.cpp | Uses NHWC for src/dst memory descriptors in shuffle example. |
| examples/primitives/resampling.cpp | Uses NHWC for src/dst memory descriptors in resampling example. |
| examples/primitives/reorder.cpp | Uses NHWC for src memory descriptor in reorder example. |
| examples/primitives/reduction.cpp | Uses NHWC for src/dst memory descriptors in reduction example. |
| examples/primitives/prelu.cpp | Updates comments and user/src MDs to NHWC in PReLU example. |
| examples/primitives/pooling.cpp | Uses NHWC for src/dst memory descriptors in pooling example. |
| examples/primitives/lrn.cpp | Uses NHWC for src/dst memory descriptors in LRN example. |
| examples/primitives/inner_product.cpp | Updates comment and uses NHWC for src memory descriptor. |
| examples/primitives/eltwise.cpp | Uses NHWC for src/dst memory descriptors in eltwise example. |
| examples/primitives/deconvolution.cpp | Updates comment and uses NHWC for user src/dst memories. |
| examples/primitives/convolution.cpp | Updates comment and uses NHWC for user src/dst memories (incl. depthwise). |
| examples/primitives/concat.cpp | Uses NHWC for source memory descriptors in concat example. |
| examples/primitives/binary.cpp | Uses NHWC for src/dst memory descriptors in binary example. |
| examples/primitives/batch_normalization.cpp | Uses NHWC for src/dst memory descriptors in batchnorm example. |
| examples/performance_profiling.cpp | Updates narrative + user memory objects for naive implementation to NHWC. |
| examples/memory_format_propagation.cpp | Updates narrative + user src/dst memory objects to NHWC. |
| examples/gpu_opencl_interop.cpp | Switches OpenCL interop example memory descriptor to NHWC and updates docs. |
| examples/cross_engine_reorder.cpp | Uses NHWC for CPU/GPU memory descriptors in cross-engine reorder example. |
| examples/cross_engine_reorder.c | Uses dnnl_nhwc for CPU/GPU memory descriptors in C cross-engine reorder. |
| examples/cpu_cnn_training_f32.c | Switches user tensors to NHWC and updates 4D init indexing for NHWC. |
| examples/cnn_training_f32.cpp | Switches user src/dst/pool tensors to NHWC (and fixes diff-weights tag). |
| examples/cnn_training_bf16.cpp | Switches user src/dst/pool tensors to NHWC (and fixes diff-weights tag). |
| examples/cnn_inference_int8.cpp | Switches user src/dst tensors to NHWC in int8 inference example. |
| examples/cnn_inference_f32.cpp | Switches user src tensor to NHWC and updates accompanying comment. |
| examples/cnn_inference_f32.c | Switches user tensors to NHWC and updates 4D init indexing for NHWC. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /// memory by passing a memory::dims object. Then we create a memory | ||
| /// descriptor with these dimensions, with the dnnl::memory::data_type::f32 | ||
| /// data type, and with the dnnl::memory::format_tag::nchw memory format. | ||
| /// data type, and with the dnnl::memory::format_tag::nhwv memory format. |
| } | ||
| } | ||
| } | ||
| } |
|
|
||
| /// Create memory that describes data layout in the buffers. This example | ||
| /// uses dnnl::memory::format_tag::nchw (batch-channels-height-width) | ||
| /// uses dnnl::memory::format_tag::nhwc (batch-channels-height-width) |
| src_dims, memory::data_type::f32, memory::format_tag::nchw); | ||
| src_dims, memory::data_type::f32, memory::format_tag::nhwc); | ||
| auto src_mem = memory(src_md, engine); | ||
| auto dst_mem = memory(src_md, engine); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Please include a summary of the change. Please also include relevant motivation and context. See contribution guidelines for more details. If the change fixes an issue not documented in the project's Github issue tracker, please document all steps necessary to reproduce it.
Fixes # (github issue)
Checklist
General
make testandmake test_benchdnn_*) pass locally for each commit?Performance improvements
New features
Bug fixes
RFC PR