Skip to content

Fix -Wundef error and dead Hexagon guard in xnnpack.h - #11141

Merged
copybara-service[bot] merged 1 commit into
google:masterfrom
digantdesai:hexagon-extra-bytes-fix
Sep 7, 2026
Merged

Fix -Wundef error and dead Hexagon guard in xnnpack.h#11141
copybara-service[bot] merged 1 commit into
google:masterfrom
digantdesai:hexagon-extra-bytes-fix

Conversation

@digantdesai

Copy link
Copy Markdown
Contributor

Consumers compiling the public header with -Wundef -Werror fail on any architecture:

error: 'XNN_ARCH_HEXAGON' is not defined, evaluates to 0
[-Werror,-Wundef] #if XNN_ARCH_HEXAGON

XNN_ARCH_HEXAGON is defined only in src/xnnpack/common.h, an internal header xnnpack.h cannot include, so the guard tested an undefined macro and the 128-byte value never took effect. HVX vectors are 1024-bit: a full-width load can read up to 128 bytes past a tensor callers padded by 16.

Deriving from hexagon keeps the internal header internal, and both definitions expand identically so neither redefinition warns.

Consumers compiling the public header with -Wundef -Werror fail on any
architecture:

  error: 'XNN_ARCH_HEXAGON' is not defined, evaluates to 0
  [-Werror,-Wundef]  #if XNN_ARCH_HEXAGON

XNN_ARCH_HEXAGON is defined only in src/xnnpack/common.h, an internal
header xnnpack.h cannot include, so the guard tested an undefined macro
and the 128-byte value never took effect. HVX vectors are 1024-bit: a
full-width load can read up to 128 bytes past a tensor callers padded
by 16.

Deriving from __hexagon__ keeps the internal header internal, and both
definitions expand identically so neither redefinition warns.
@copybara-service
copybara-service Bot merged commit 6c19e6b into google:master Sep 7, 2026
28 of 30 checks passed
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.

2 participants