Enhance dropout
Context
This Merge Request adds full support for the ONNX Dropout
operator (opset ≥ 12), based on the ONNX specification. It introduces three key features:
-
training_mode
input (optional)- A boolean scalar input that controls whether dropout is applied (
True
) or bypassed (False
). - If omitted, it defaults to inference mode (
True
), meaning dropout is applied. - Enables dynamic control of training vs. inference behavior at runtime.
- A boolean scalar input that controls whether dropout is applied (
-
mask
output (optional second output)- A boolean tensor of the same shape as the input.
- Indicates which elements were retained (
True
) or dropped (False
) during dropout. - Useful for debugging, backpropagation, or custom downstream logic.
-
`seed attribute (optional)
- A fixed integer value used to seed the random number generator for dropout.
- Ensures reproducibility of the dropout mask across runs when provided.
- If omitted, a random seed is used (non-deterministic behavior).
resolves issue aidge_core#321
Implementation Details
-
Added parsing and validation for the optional
training_mode
input:- Defaults to
True
(training mode) if not provided - Disables dropout logic when
training_mode=False
- Defaults to
-
Implemented generation of the
mask
tensor when the second output is requested:- Mask is a boolean tensor indicating retained elements
- Same mask is used to compute the final output
-
Supported the optional
seed
attribute for deterministic behavior:- When provided, it seeds the dropout RNG
- Guarantees reproducible masks across runs
-
Updated operator registry and unit tests accordingly
TODO
-
training_mode
attribute -
mask
output -
seed
attribute -
unit_tests
Edited by Houssem ROUIS