Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: issue 278 LayerNorm - #281

#281
Merged
Alwaysssssss merged 3 commits into
nndeploy:mainnndeploy/nndeploy:mainfrom
Edwardssss:feat/issue-278-layernormEdwardssss/nndeploy:feat/issue-278-layernormCopy head branch name to clipboard
Apr 22, 2026
Merged

feat: issue 278 LayerNorm#281
Alwaysssssss merged 3 commits into
nndeploy:mainnndeploy/nndeploy:mainfrom
Edwardssss:feat/issue-278-layernormEdwardssss/nndeploy:feat/issue-278-layernormCopy head branch name to clipboard

Conversation

@Edwardssss

Copy link
Copy Markdown
Contributor

Description

This PR adds LayerNorm operator support across:

  • Core C++ IR/Op (CPU reference + x86 oneDNN backend)
  • Python bindings and functional API
  • Unit tests

PR Type

Please check the type of change your PR introduces:

  • Bugfix
  • Feature
  • Refactoring
  • Documentation
  • Other (please specify):

Related Issues

Resolves #278 (LayerNorm implementation item)

Changes Made

  1. Core C++ IR & Op

    • Added kOpTypeLayerNormalization in op_param.h/.cc and string mappings.
    • Added LayerNormalizationParam with epsilon_.
    • Implemented CPU reference operator:
      • framework/include/nndeploy/op/op_layernorm.h
      • framework/source/nndeploy/op/op_layernorm.cc
    • Implemented x86 oneDNN operator:
      • framework/source/nndeploy/op/x86/op_layernorm.cc
  2. Python API Exposure

    • Added IR enum/param exposure in python/src/ir/op_param.cc.
    • Added op bridge and pybind exposure:
      • python/src/op/op_func.h
      • python/src/op/op_func.cc
      • python/src/op/op.cc
    • Added user-facing functional API:
      • python/nndeploy/op/functional.py (layer_norm)
    • Updated Python OpType mapping:
      • python/nndeploy/ir/op_param.py
  3. Testing

    • Added test/op/test_layer_norm.py with:
      • last-dim LayerNorm with affine (weight + bias)
      • multi-dim normalization without bias
    • Numpy reference is used for correctness checking.

Checklist

  • Follows the project's coding style
  • Adds unit tests for the new feature
  • Code compiles successfully
  • Clear commit history

Testing

cmake -S . -B build && cmake --build build -j4
# passed

PYTHONPATH=python LD_LIBRARY_PATH=build:$LD_LIBRARY_PATH python test/op/test_layer_norm.py
..
----------------------------------------------------------------------
Ran 2 tests in 0.012s

Edwardssss and others added 3 commits April 19, 2026 23:13
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Alwaysssssss
Alwaysssssss merged commit 4ad43d9 into nndeploy:main Apr 22, 2026
8 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.

feat: 原生实现 Z-Image(基于分数的生成模型)支持

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.