Skip to content

Cadence HiFi: Fix build errors for ResNet-18 and Emformer RNNT Encoder#18659

Merged
rascani merged 1 commit intopytorch:mainfrom
rascani:fix-cadence-hifi-build
Apr 2, 2026
Merged

Cadence HiFi: Fix build errors for ResNet-18 and Emformer RNNT Encoder#18659
rascani merged 1 commit intopytorch:mainfrom
rascani:fix-cadence-hifi-build

Conversation

@rascani
Copy link
Copy Markdown
Contributor

@rascani rascani commented Apr 1, 2026

Summary

Fix several HiFi build issues preventing ResNet-18 and Emformer RNNT Encoder from compiling and running on the Xtensa toolchain.

Fixes #18181

functions_hifi.yaml:

  • Add quantized_max_pool2d_nchw op (NCHW variant was missing, only NHWC was registered). Uses generic fallback kernel.
  • Add native_layer_norm op (needed by Emformer RNNT Encoder). Uses portable kernel.
  • Fix double native:: namespace on quantized_conv1d_ncl and quantized_conv1d_nlc kernel names — codegen adds the native:: namespace automatically, so having it in the yaml produced impl::HiFi::native::native:: which failed to link.

CMakeLists.txt:

  • Add op_quantized_max_pool2d_nhwc.cpp to custom_ops sources (file existed but was not compiled)
  • Add generic conv1d fallback sources (op_quantized_conv1d_ncl.cpp, op_quantized_conv1d_nlc.cpp) that HiFi conv1d operators call
  • Add generic op_quantized_max_pool2d.cpp for NCHW fallback
  • Add portable op_native_layer_norm.cpp and normalization_ops_util.cpp

install_requirements.sh:

  • Update nnlib-hifi4 SHA to 64d73d72 which adds xa_nn_elm_add_broadcast_4D_f32xf32_f32 (float broadcast add kernel used by op_add.cpp)

Authored with Claude.

Test Plan

  CXXFLAGS="-fno-exceptions -fno-rtti" cmake \
    -DCMAKE_TOOLCHAIN_FILE=./backends/cadence/cadence.cmake \
    -DCMAKE_INSTALL_PREFIX=cmake-xtensa \
    -DCMAKE_BUILD_TYPE=Release \
    -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=ON \
    -DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
    -DEXECUTORCH_BUILD_CPUINFO=OFF \
    -DEXECUTORCH_BUILD_CADENCE=ON \
    -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
    -DEXECUTORCH_ENABLE_LOGGING=ON \
    -DEXECUTORCH_ENABLE_PROGRAM_VERIFICATION=ON \
    -DEXECUTORCH_USE_DL=OFF \
    -DEXECUTORCH_BUILD_PORTABLE_OPS=ON \
    -DEXECUTORCH_BUILD_KERNELS_LLM=OFF \
    -DPYTHON_EXECUTABLE=python3 \
    -DEXECUTORCH_NNLIB_OPT=ON \
    -DHAVE_FNMATCH_H=OFF \
    -DFLATCC_ALLOW_WERROR=OFF \
    -Bcmake-xtensa
  cmake --build cmake-xtensa --target install --config Release -j8

Fix several HiFi build issues preventing ResNet-18 and Emformer RNNT
Encoder from compiling and running on the Xtensa toolchain.

functions_hifi.yaml:
- Add quantized_max_pool2d_nchw op (NCHW variant was missing, only
  NHWC was registered). Uses generic fallback kernel.
- Add native_layer_norm op (needed by Emformer RNNT Encoder). Uses
  portable kernel.
- Fix double native:: namespace on quantized_conv1d_ncl and
  quantized_conv1d_nlc kernel names — codegen adds the native::
  namespace automatically, so having it in the yaml produced
  impl::HiFi::native::native:: which failed to link.

CMakeLists.txt:
- Add op_quantized_max_pool2d_nhwc.cpp to custom_ops sources (file
  existed but was not compiled)
- Add generic conv1d fallback sources (op_quantized_conv1d_ncl.cpp,
  op_quantized_conv1d_nlc.cpp) that HiFi conv1d operators call
- Add generic op_quantized_max_pool2d.cpp for NCHW fallback
- Add portable op_native_layer_norm.cpp and normalization_ops_util.cpp

install_requirements.sh:
- Update nnlib-hifi4 SHA to 64d73d72 which adds
  xa_nn_elm_add_broadcast_4D_f32xf32_f32 (float broadcast add kernel
  used by op_add.cpp)

Authored with Claude.
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot bot commented Apr 1, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/18659

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 Cancelled Jobs

As of commit d5c7fb6 with merge base 6bd9bca (image):

CANCELLED JOBS - The following jobs were cancelled. Please retry:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@rascani rascani merged commit 463006a into pytorch:main Apr 2, 2026
165 of 168 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Building failed for Cadence target

2 participants