Lock all dependencies to exact versions for reproducible ONNX graph generation#5
Merged
runwangdl merged 7 commits intopulp-platform:develfrom Feb 19, 2026
Merged
Conversation
This commit adds support for the ONNX Sub (subtraction) operator: - Created SubOperatorTest class in onnx4deeploy/operators/sub.py * Implements element-wise binary subtraction (A - B) * Supports Numpy-style broadcasting * Based on ONNX Opset 14 specification * Uses SimpleElementwiseOperator base class - Registered Sub operator in onnx4deeploy/operators/__init__.py - Added default configuration in onnx4deeploy/operators/config.yaml * Default input shape: [1, 64, 32, 32] (NCHW format) * Opset version: 14 - Added comprehensive pytest tests in tests/operators/test_operators.py * test_sub_basic: Verifies basic functionality * test_sub_different_shapes: Tests multiple input shapes * test_sub_result_range: Validates output range correctness * All tests passing ✓ Generated test files validated: - network.onnx: Sub operator graph - inputs.npz: Two input tensors (input_a, input_b) - outputs.npz: Expected output (A - B) - Numerical verification: max difference = 0.000000e+00 Reference: https://onnx.ai/onnx/operators/onnx__Sub.html Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Different environments (e.g., different versions of
torch,onnx,onnxscript, etc.)produce different ONNX graph structures, making cross-environment reproducibility impossible.
This PR pins all core dependencies to the exact versions used in the reference environment
to guarantee identical ONNX graph generation regardless of where the code is run.
Changes
requirements.txt: Replace all range constraints (>=,<) with exact version pins (==)pyproject.toml: Same pinning independencies; narrowrequires-pythonfrom>=3.9to==3.10.*Pinned Environment
Motivation
ONNX graph generation is sensitive to library internals (operator fusion, constant folding,
node ordering, opset handling, etc.). Allowing version ranges silently permits environment
drift that produces structurally different graphs — breaking downstream deployment pipelines
that rely on a stable graph topology.
Impact
Installing in an environment that does not match these exact versions will now fail
explicitly rather than silently producing a divergent ONNX graph.