Skip to content

Add MobileNetV3 operators support to aidge_onnx

Context

This MR is linked to aidge#299 (closed).

This MR aims to add ONNX operators declaration to support MobileNet-v3 Small. The current ONNX model (https://huggingface.co/qualcomm/MobileNet-v3-Small/resolve/main/MobileNet-v3-Small.onnx) uses two operators not yet implemented in Aidge:

  • HardSigmoid
  • HardSwish

HardSigmoid - ONNX Framework Implementation

ONNX Framework Files

  • hardsigmoid.py (50 lines) - ONNX import converter with attribute handling
  • hardsigmoid.py (43 lines) - ONNX export converter with attribute preservation

ONNX Import Architecture

  • Attribute Handling: Extracts alpha/beta attributes from ONNX nodes with default values (alpha=0.2, beta=0.5)
  • Error Handling: Warns about unsupported attributes and falls back to GenericOperator
  • Node Creation: Creates aidge_core.HardSigmoid nodes with proper attribute mapping

ONNX Export Architecture

  • Attribute Preservation: Exports alpha/beta attributes to ONNX format using helper.make_attribute
  • Node Creation: Creates ONNX HardSigmoid nodes with proper input/output mapping
  • ONNX Compliance: Follows ONNX HardSigmoid operator specification

HardSwish - ONNX Framework Implementation

ONNX Framework Files

  • hardswish.py (42 lines) - ONNX import converter for HardSwish meta-operator
  • hardswish.py (31 lines) - ONNX export converter for HardSwish meta-operator

ONNX Import Architecture

  • Meta-Operator Support: Direct import of HardSwish meta-operator without attribute processing
  • Fixed Values: ONNX HardSwish uses fixed alpha/beta values (alpha=1/6, beta=0.5) - no attributes exposed
  • Error Handling: Warns about unsupported attributes and falls back to GenericOperator
  • Node Creation: Creates aidge_core.HardSwish nodes with name preservation

ONNX Export Architecture

  • Fixed Values: ONNX HardSwish uses fixed alpha/beta values (no attribute export)
  • Node Creation: Creates ONNX HardSwish nodes without custom attributes
  • ONNX Compliance: Follows ONNX HardSwish operator specification (opset 14+)

MobileNet-V3-Small in Model Zoo

  • Testing unit_tests/test_model_zoo.py

External References

Edited by matthieu marchal

Merge request reports

Loading