Skip to content

examples: switch to nhwc#8

Open
vgvozdeva wants to merge 15 commits into
mainfrom
vgvozdeva/examples
Open

examples: switch to nhwc#8
vgvozdeva wants to merge 15 commits into
mainfrom
vgvozdeva/examples

Conversation

@vgvozdeva

Copy link
Copy Markdown
Owner

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

  • Do all unit and benchdnn tests (make test and make test_benchdnn_*) pass locally for each commit?
  • Have you formatted the code using clang-format?

Performance improvements

  • Have you submitted performance data that demonstrates performance improvements?

New features

  • Have you published an RFC for the new feature?
  • Was the RFC approved?
  • Have you added relevant tests?

Bug fixes

  • Have you included information on how to reproduce the issue (either in a github issue or in this PR)?
  • Have you added relevant regression tests?

RFC PR

  • Does RFC document follow the template?
  • Have you added a link to the rendered document?

@vgvozdeva vgvozdeva force-pushed the vgvozdeva/examples branch from 482c9b2 to 23d2f48 Compare May 6, 2026 07:48
@vgvozdeva

vgvozdeva commented May 7, 2026

Copy link
Copy Markdown
Owner Author

make test
set test_scope=NIGHTLY

@vgvozdeva

Copy link
Copy Markdown
Owner Author

make test
set test_scope=NIGHTLY

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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_nchw to nhwc/dnnl_nhwc across 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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants