Skip to content

Add recipe: remove nop_dropout

matthieu marchal requested to merge mm/feature/recipes_dropout into dev

Context

This MR is part of #83

Problem: ONNX models contain dropout layers with probability=0.0 that act as no-ops during inference, adding unnecessary computational overhead.

Solution: Implement a new recipe to automatically detect and remove these redundant dropout nodes while preserving model functionality.

Required fix: The dropout node implementation should be updated to follow ONNX specification more closely (see issue aidge_core#321).

Modified files

  • recipes/nop_dropout.py - New recipe implementation
  • recipes/__init__.py - Recipe registration
  • unit_tests/onnx_cleaner_models/nop_dropout.py - Test cases
  • unit_tests/onnx_cleaner_models/__init__.py - Test integration
  • unit_tests/test_onnx_cleaner.py - Test suite update

Detailed major modifications

Recipe Logic:

  • Filters dropout nodes with probability=0.0 and simple connections (≤1 children)
  • Uses SinglePassGraphMatching for safe node removal
  • Preserves complex connections to avoid breaking graph structure

Test Coverage:

  • Input/output dropout removal scenarios
  • Complex connection preservation
  • Non-zero probability preservation

TODO

  • Basic implementation
  • Test coverage
  • Pipeline integration
  • Updated attributes handling (training_mode)
  • Complex connection handling
Edited by matthieu marchal

Merge request reports

Loading