onnx2fx 0.0.0__tar.gz → 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. onnx2fx-0.0.1/.github/workflows/ci.yml +54 -0
  2. onnx2fx-0.0.1/.github/workflows/publish.yml +33 -0
  3. onnx2fx-0.0.1/.gitignore +85 -0
  4. onnx2fx-0.0.1/.pre-commit-config.yaml +7 -0
  5. onnx2fx-0.0.1/AGENTS.md +212 -0
  6. onnx2fx-0.0.1/LICENSE +201 -0
  7. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/PKG-INFO +13 -4
  8. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/README.md +8 -0
  9. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/pyproject.toml +15 -13
  10. onnx2fx-0.0.1/tests/conftest.py +455 -0
  11. onnx2fx-0.0.1/tests/smoke_test.py +4 -0
  12. onnx2fx-0.0.1/tests/test_activation.py +159 -0
  13. onnx2fx-0.0.1/tests/test_arithmetic.py +363 -0
  14. onnx2fx-0.0.1/tests/test_attention.py +1334 -0
  15. onnx2fx-0.0.1/tests/test_attribute.py +111 -0
  16. onnx2fx-0.0.1/tests/test_constant.py +57 -0
  17. onnx2fx-0.0.1/tests/test_control_flow.py +373 -0
  18. onnx2fx-0.0.1/tests/test_custom_ops.py +407 -0
  19. onnx2fx-0.0.1/tests/test_dtype_mapping.py +40 -0
  20. onnx2fx-0.0.1/tests/test_dynamic_shapes.py +582 -0
  21. onnx2fx-0.0.1/tests/test_e2e_models.py +548 -0
  22. onnx2fx-0.0.1/tests/test_einsum.py +61 -0
  23. onnx2fx-0.0.1/tests/test_image.py +93 -0
  24. onnx2fx-0.0.1/tests/test_initializer.py +79 -0
  25. onnx2fx-0.0.1/tests/test_lfm25_model.py +209 -0
  26. onnx2fx-0.0.1/tests/test_lfm2_model.py +196 -0
  27. onnx2fx-0.0.1/tests/test_loss.py +108 -0
  28. onnx2fx-0.0.1/tests/test_math.py +177 -0
  29. onnx2fx-0.0.1/tests/test_nn.py +447 -0
  30. onnx2fx-0.0.1/tests/test_onnx_backend_test.py +288 -0
  31. onnx2fx-0.0.1/tests/test_onnx_ops.py +47 -0
  32. onnx2fx-0.0.1/tests/test_opset_versions.py +587 -0
  33. onnx2fx-0.0.1/tests/test_paddleocr_models.py +298 -0
  34. onnx2fx-0.0.1/tests/test_quantization.py +550 -0
  35. onnx2fx-0.0.1/tests/test_random.py +83 -0
  36. onnx2fx-0.0.1/tests/test_sequence.py +151 -0
  37. onnx2fx-0.0.1/tests/test_smolvlm_models.py +428 -0
  38. onnx2fx-0.0.1/tests/test_tensor_ops.py +456 -0
  39. onnx2fx-0.0.1/tests/test_tinyllama.py +465 -0
  40. onnx2fx-0.0.1/tests/test_torchvision_models.py +152 -0
  41. onnx2fx-0.0.1/tests/test_training.py +433 -0
  42. onnx2fx-0.0.1/uv.lock +1479 -0
  43. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/__init__.py +0 -0
  44. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/converter.py +0 -0
  45. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/exceptions.py +0 -0
  46. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/graph_builder.py +0 -0
  47. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/op_registry.py +0 -0
  48. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/__init__.py +0 -0
  49. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/activation.py +0 -0
  50. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/arithmetic.py +0 -0
  51. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/attention.py +0 -0
  52. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/attention_msft.py +0 -0
  53. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/control_flow.py +0 -0
  54. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/convolution.py +0 -0
  55. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/image.py +0 -0
  56. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/linalg.py +0 -0
  57. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/loss.py +0 -0
  58. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/nn.py +0 -0
  59. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/normalization.py +0 -0
  60. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/pooling.py +0 -0
  61. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/quantization.py +0 -0
  62. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/random.py +0 -0
  63. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/recurrent.py +0 -0
  64. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/reduction.py +0 -0
  65. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/sequence.py +0 -0
  66. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/signal.py +0 -0
  67. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/string.py +0 -0
  68. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/tensor.py +0 -0
  69. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/ops/training.py +0 -0
  70. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/py.typed +0 -0
  71. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/__init__.py +0 -0
  72. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/analyze.py +0 -0
  73. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/attributes.py +0 -0
  74. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/dtype.py +0 -0
  75. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/external_data.py +0 -0
  76. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/names.py +0 -0
  77. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/op_helpers.py +0 -0
  78. {onnx2fx-0.0.0 → onnx2fx-0.0.1}/src/onnx2fx/utils/training.py +0 -0
@@ -0,0 +1,54 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v6
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v7
17
+
18
+ - name: Set up Python
19
+ uses: actions/setup-python@v6
20
+ with:
21
+ python-version: "3.12"
22
+
23
+ - name: Install dependencies
24
+ run: uv sync
25
+
26
+ - name: Run Ruff linter
27
+ run: uv run ruff check .
28
+
29
+ - name: Run Ruff formatter
30
+ run: uv run ruff format --check .
31
+
32
+ test:
33
+ runs-on: ubuntu-latest
34
+ strategy:
35
+ fail-fast: false
36
+ matrix:
37
+ python-version: ["3.11", "3.12", "3.13"]
38
+
39
+ steps:
40
+ - uses: actions/checkout@v6
41
+
42
+ - name: Install uv
43
+ uses: astral-sh/setup-uv@v7
44
+
45
+ - name: Set up Python ${{ matrix.python-version }}
46
+ uses: actions/setup-python@v6
47
+ with:
48
+ python-version: ${{ matrix.python-version }}
49
+
50
+ - name: Install dependencies
51
+ run: uv sync --dev
52
+
53
+ - name: Run tests
54
+ run: uv run pytest -v tests -m "not slow"
@@ -0,0 +1,33 @@
1
+ name: Publish
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ run:
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v6
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v7
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v6
23
+ with:
24
+ python-version-file: "pyproject.toml"
25
+ - name: Build
26
+ run: uv build
27
+ # Check that basic features work and we didn't miss to include crucial files
28
+ - name: Smoke test (wheel)
29
+ run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
30
+ - name: Smoke test (source distribution)
31
+ run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
32
+ - name: Publish
33
+ run: uv publish
@@ -0,0 +1,85 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # Installer logs
30
+ pip-log.txt
31
+ pip-delete-this-directory.txt
32
+
33
+ # Unit test / coverage reports
34
+ htmlcov/
35
+ .tox/
36
+ .nox/
37
+ .coverage
38
+ .coverage.*
39
+ .cache
40
+ nosetests.xml
41
+ coverage.xml
42
+ *.cover
43
+ *.py.cover
44
+ .hypothesis/
45
+ .pytest_cache/
46
+ cover/
47
+
48
+ # pyenv
49
+ # For a library or package, you might want to ignore these files since the code is
50
+ # intended to run in multiple environments; otherwise, check them in:
51
+ .python-version
52
+
53
+ # UV
54
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
55
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
56
+ # commonly ignored for libraries.
57
+ # uv.lock
58
+
59
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
60
+ __pypackages__/
61
+
62
+ # Environments
63
+ .env
64
+ .envrc
65
+ .venv
66
+ env/
67
+ venv/
68
+ ENV/
69
+ env.bak/
70
+ venv.bak/
71
+
72
+ # Visual Studio Code
73
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
74
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
75
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
76
+ # you could uncomment the following to ignore the entire vscode folder
77
+ .vscode/
78
+
79
+ # Ruff stuff:
80
+ .ruff_cache/
81
+
82
+ # PyPI configuration file
83
+ .pypirc
84
+
85
+ tests/.model_cache/
@@ -0,0 +1,7 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.14.10
4
+ hooks:
5
+ - id: ruff
6
+ args: [ --fix ]
7
+ - id: ruff-format
@@ -0,0 +1,212 @@
1
+ # AGENTS.md
2
+
3
+ ## Project Overview
4
+
5
+ **onnx2fx** is a Python library that converts ONNX models into PyTorch FX `GraphModule`s. This enables seamless integration with PyTorch's ecosystem for optimization, analysis, and deployment.
6
+
7
+ ## Repository Structure
8
+
9
+ ```
10
+ onnx2fx/
11
+ ├── src/onnx2fx/ # Main package
12
+ │ ├── __init__.py # Public API exports
13
+ │ ├── converter.py # Entry point (convert function)
14
+ │ ├── graph_builder.py # FX graph construction logic
15
+ │ ├── op_registry.py # Operator registration system
16
+ │ ├── exceptions.py # Custom exception classes
17
+ │ ├── ops/ # ONNX operator implementations
18
+ │ │ ├── activation.py # Activation functions (Relu, Sigmoid, etc.)
19
+ │ │ ├── arithmetic.py # Arithmetic ops (Add, Mul, Sin, Cos, etc.)
20
+ │ │ ├── attention.py # Attention ops (MultiHeadAttention, etc.)
21
+ │ │ ├── attention_msft.py # Microsoft domain attention ops
22
+ │ │ ├── control_flow.py # Control flow ops (Loop, If, Scan)
23
+ │ │ ├── convolution.py # Convolution ops (Conv, ConvTranspose, DeformConv)
24
+ │ │ ├── image.py # Image ops (Resize, DepthToSpace, etc.)
25
+ │ │ ├── linalg.py # Linear algebra ops (Einsum, Det)
26
+ │ │ ├── loss.py # Loss functions (SoftmaxCrossEntropyLoss, etc.)
27
+ │ │ ├── nn.py # Core neural network ops (MatMul, Gemm, Dropout)
28
+ │ │ ├── normalization.py # Normalization ops (BatchNorm, LayerNorm, etc.)
29
+ │ │ ├── pooling.py # Pooling ops (MaxPool, AveragePool, etc.)
30
+ │ │ ├── quantization.py # Quantization ops (QLinear*, etc.)
31
+ │ │ ├── random.py # Random ops (RandomNormal, Bernoulli, etc.)
32
+ │ │ ├── recurrent.py # Recurrent neural networks (LSTM, GRU, RNN)
33
+ │ │ ├── reduction.py # Reduction ops (Sum, Mean, etc.)
34
+ │ │ ├── sequence.py # Sequence ops (SequenceConstruct, etc.)
35
+ │ │ ├── signal.py # Signal processing (STFT, MelWeightMatrix, window functions, NMS)
36
+ │ │ ├── string.py # String ops (StringNormalizer)
37
+ │ │ ├── tensor.py # Tensor ops (Reshape, Transpose, etc.)
38
+ │ │ └── training.py # Training ops (Gradient, Momentum, Adagrad)
39
+ │ └── utils/ # Utility modules
40
+ │ ├── analyze.py # Model analysis utilities
41
+ │ ├── attributes.py # ONNX attribute parsing
42
+ │ ├── dtype.py # ONNX to PyTorch dtype mapping
43
+ │ ├── external_data.py # External data utilities
44
+ │ ├── names.py # Name sanitization utilities
45
+ │ ├── op_helpers.py # Op helper utilities
46
+ │ └── training.py # Training utilities (make_trainable)
47
+ ├── tests/ # Test suite
48
+ └── pyproject.toml # Project configuration
49
+ ```
50
+
51
+ ## Development Setup
52
+
53
+ ```bash
54
+ # Clone and install in development mode (using uv for faster dependency resolution)
55
+ git clone https://github.com/mshr-h/onnx2fx.git
56
+ cd onnx2fx
57
+ uv sync --dev
58
+
59
+ # Run Python scripts using uv
60
+ uv run python your_script.py
61
+ ```
62
+
63
+ Core Requirements:
64
+ - Python >= 3.11
65
+ - PyTorch >= 2.9.0
66
+ - ONNX >= 1.19.1
67
+
68
+ Development Tools:
69
+ - uv (recommended for development)
70
+ - See `pyproject.toml` for full list of development dependencies
71
+
72
+ ## Running Tests
73
+
74
+ ```bash
75
+ # Run all tests
76
+ uv run pytest
77
+
78
+ # Run all tests in parallel for faster execution
79
+ uv run pytest -n auto
80
+
81
+ # Run tests excluding slow tests
82
+ uv run pytest -m "not slow"
83
+
84
+ # Run specific test file
85
+ uv run pytest tests/test_activation.py
86
+
87
+ # Run with verbose output
88
+ uv run pytest -v
89
+ ```
90
+
91
+ ## Code Style
92
+
93
+ This project uses `ruff` for linting and formatting. Run before committing:
94
+
95
+ ```bash
96
+ uv run ruff check .
97
+ uv run ruff format .
98
+ ```
99
+
100
+ ## Adding New ONNX Operators
101
+
102
+ 1. **Choose the appropriate file** in `src/onnx2fx/ops/` based on operator category.
103
+
104
+ 2. **Register the operator** using the `@register` decorator:
105
+
106
+ ```python
107
+ import torch
108
+ from ..op_registry import register
109
+ from ..utils.attributes import get_attribute
110
+
111
+ @register("NewOp") # Standard ONNX domain
112
+ def new_op(builder, node):
113
+ x = builder.get_value(node.input[0])
114
+ alpha = get_attribute(node, "alpha", default=1.0) # Get ONNX attribute
115
+ return builder.call_function(torch.some_func, args=(x, alpha))
116
+ ```
117
+
118
+ 3. **For version-specific behavior**, use `since_version`:
119
+
120
+ ```python
121
+ @register("SomeOp", since_version=1)
122
+ def some_op_v1(builder, node):
123
+ # Behavior for opset 1-12
124
+ ...
125
+
126
+ @register("SomeOp", since_version=13)
127
+ def some_op_v13(builder, node):
128
+ # Behavior for opset 13+
129
+ ...
130
+ ```
131
+
132
+ 4. **For custom domains** (e.g., Microsoft operators):
133
+
134
+ ```python
135
+ @register("BiasGelu", domain="com.microsoft")
136
+ def bias_gelu(builder, node):
137
+ ...
138
+ ```
139
+
140
+ 5. **Add tests** in the appropriate test file under `tests/`.
141
+
142
+ ## Key APIs
143
+
144
+ ### GraphBuilder Methods
145
+
146
+ - `builder.get_value(name)` - Get FX node by ONNX tensor name
147
+ - `builder.has_value(name)` - Check if value exists in environment
148
+ - `builder.call_function(func, args, kwargs)` - Create function call node
149
+ - `builder.call_module(module_name, args, kwargs)` - Create module call node
150
+ - `builder.register_submodule(name, module)` - Register a submodule (returns safe name)
151
+ - `builder.opset_version` - Get current opset version for default domain
152
+ - `builder.get_opset_version(domain)` - Get opset version for specific domain
153
+
154
+ ### Attribute Utilities
155
+
156
+ For parsing ONNX node attributes, use functions from `onnx2fx.utils.attributes`:
157
+
158
+ - `get_attribute(node, name, default)` - Get a single attribute from an ONNX node
159
+ - `get_attributes(node)` - Get all attributes as a dictionary
160
+
161
+ ### Public API
162
+
163
+ #### Core Functions
164
+ - `convert(model, *, base_dir=None, memmap_external_data=False)` - Convert ONNX model to FX GraphModule
165
+ - `make_trainable(module)` - Convert buffers to trainable parameters for training
166
+
167
+ #### Model Analysis
168
+ - `analyze_model(model)` - Analyze ONNX model for operator support
169
+ - `AnalysisResult` - Dataclass with analysis results (supported_ops, unsupported_ops, etc.)
170
+
171
+ #### Operator Registration
172
+ - `register_op(op_type, handler=None, domain="", since_version=1)` - Register custom operator
173
+ - `unregister_op(op_type, domain="", since_version=None)` - Unregister an operator handler
174
+ - `is_supported(op_type, domain)` - Check if operator is supported
175
+ - `get_supported_ops(domain)` - List supported operators for a domain
176
+ - `get_all_supported_ops()` - Get all supported operators across all domains
177
+ - `get_registered_domains()` - Get list of registered domains
178
+
179
+ #### Exceptions
180
+ - `Onnx2FxError` - Base exception for all onnx2fx errors
181
+ - `UnsupportedOpError` - Raised when an operator is not supported
182
+ - `ConversionError` - Raised when conversion fails
183
+ - `ValueNotFoundError` - Raised when a value is not found in environment
184
+
185
+ ## Testing Guidelines
186
+
187
+ - Use `onnxscript` to create test ONNX models programmatically
188
+ - Test across multiple opset versions using `conftest.py` fixtures
189
+ - Compare outputs with ONNX Runtime for numerical correctness
190
+ - Mark slow tests (e.g., large models) with `@pytest.mark.slow`
191
+
192
+ ### Test Fixtures (from `conftest.py`)
193
+
194
+ - `OPSET_MODULES` - List of opset modules (opset 11-23) for parametrized tests
195
+ - `EINSUM_OPSET_MODULES` - Opset modules supporting Einsum (opset 12+)
196
+ - `DEFAULT_OPSET` - Default opset module (opset23)
197
+ - `opset_id(opset)` - Helper function for parametrize ids
198
+
199
+ Example parametrized test:
200
+ ```python
201
+ import pytest
202
+ from conftest import OPSET_MODULES, opset_id
203
+
204
+ @pytest.mark.parametrize("opset", OPSET_MODULES, ids=opset_id)
205
+ def test_my_op(opset):
206
+ # Test with each opset version
207
+ ...
208
+ ```
209
+
210
+ ## License
211
+
212
+ Apache-2.0
onnx2fx-0.0.1/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -1,12 +1,13 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: onnx2fx
3
- Version: 0.0.0
3
+ Version: 0.0.1
4
4
  Summary: Yet another ONNX to PyTorch FX converter
5
- Author: Masahiro Hiramori
5
+ Project-URL: Homepage, https://github.com/mshr-h/onnx2fx
6
6
  Author-email: Masahiro Hiramori <contact@mshr-h.com>
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
7
9
  Requires-Dist: onnx>=1.19.1
8
10
  Requires-Dist: torch>=2.9.0
9
- Requires-Python: >=3.11
10
11
  Description-Content-Type: text/markdown
11
12
 
12
13
  # onnx2fx
@@ -48,6 +49,14 @@ The following models have been tested and verified to work with onnx2fx:
48
49
  - PyTorch >= 2.9.0
49
50
  - ONNX >= 1.19.1
50
51
 
52
+ ### From PyPI
53
+
54
+ ```bash
55
+ pip install onnx2fx
56
+ # or
57
+ uv pip install onnx2fx
58
+ ```
59
+
51
60
  ### From Source
52
61
 
53
62
  ```bash
@@ -37,6 +37,14 @@ The following models have been tested and verified to work with onnx2fx:
37
37
  - PyTorch >= 2.9.0
38
38
  - ONNX >= 1.19.1
39
39
 
40
+ ### From PyPI
41
+
42
+ ```bash
43
+ pip install onnx2fx
44
+ # or
45
+ uv pip install onnx2fx
46
+ ```
47
+
40
48
  ### From Source
41
49
 
42
50
  ```bash
@@ -1,20 +1,24 @@
1
1
  [project]
2
2
  name = "onnx2fx"
3
- version = "0.0.0"
3
+ dynamic = ["version"]
4
4
  description = "Yet another ONNX to PyTorch FX converter"
5
5
  readme = "README.md"
6
- authors = [
7
- { name = "Masahiro Hiramori", email = "contact@mshr-h.com" }
8
- ]
6
+ urls = { "Homepage" = "https://github.com/mshr-h/onnx2fx" }
7
+ authors = [{ name = "Masahiro Hiramori", email = "contact@mshr-h.com" }]
9
8
  requires-python = ">=3.11"
10
- dependencies = [
11
- "onnx>=1.19.1",
12
- "torch>=2.9.0",
13
- ]
9
+ dependencies = ["onnx>=1.19.1", "torch>=2.9.0"]
10
+ license-files = ["LICENSE"]
14
11
 
15
12
  [build-system]
16
- requires = ["uv_build>=0.8.19,<0.9.0"]
17
- build-backend = "uv_build"
13
+ requires = ["hatchling", "hatch-vcs"]
14
+ build-backend = "hatchling.build"
15
+
16
+ [tool.hatch.version]
17
+ source = "vcs"
18
+ fallback-version = "0.0.0"
19
+
20
+ [tool.hatch.build.targets.wheel]
21
+ packages = ["src/onnx2fx"]
18
22
 
19
23
  [dependency-groups]
20
24
  dev = [
@@ -32,9 +36,7 @@ dev = [
32
36
 
33
37
  [tool.pytest.ini_options]
34
38
  pythonpath = ["src"]
35
- markers = [
36
- "slow: marks tests as slow (deselect with '-m \"not slow\"')",
37
- ]
39
+ markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"]
38
40
  # Asyncio mode for pytest-asyncio (auto mode for convenience)
39
41
  asyncio_mode = "auto"
40
42
  asyncio_default_fixture_loop_scope = "function"