pytorch/test/onnx
Justin Chu 5d67efb809 [ONNX] New registration API (#135403)
The ONNX custom ops registration API.

## Design

1. Create a "custom_translation_table: dict[Callable, Sequence[Callable] | Callable" parameter for specifying extra functions
2. Use a callable as the key to support all possible call_function targets in the fx graph
3. Allow a callable or a Sequence of callables as values.
		- When there is a single callable, it is the translation function for the op
		- When there is a Sequence of callable, the exporter's dispatcher will dispatch to these callables in order based on input dtypes.
		- The translation functions can be a plain python function that calls onnxscript ops (traced), or an onnxscript function.
		- Complex input support: We create special type annotations for annotating real representations of complex inputs, which are needed to handle complex computation in the ONNX graph, as we don't have any ops in ONNX that handle complex inputs. The dispatcher will have knowledge of these newly created type annotations and dispatch correctly. The complex functions will be in the same overload pool as the real functions.

```py
torch.onnx.export(dynamo=True,
	custom_translation_table = {
	torch.ops.aten.add: [overload1, overload2],
	torch.sym_not: sym_not_onnx,
})
```
Support for functions that handles complex inputs will be in separate PRs.

fixes https://github.com/pytorch/pytorch/issues/138391

Pull Request resolved: https://github.com/pytorch/pytorch/pull/135403
Approved by: https://github.com/titaiwangms
2024-11-01 20:58:54 +00:00
..
assets
dynamo [ONNX] Refactor exporter errors (#135180) 2024-09-07 00:50:15 +00:00
expect [ONNX] Remove the operators test (#136335) 2024-09-25 17:44:18 +00:00
exporter [ONNX] New registration API (#135403) 2024-11-01 20:58:54 +00:00
internal [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
model_defs [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
torch_export [ONNX] Enable experimental exporter logic to dynamo_export and support refine dynamic_shapes (#134976) 2024-09-06 01:29:56 +00:00
autograd_helper.py
error_reproduction.py [BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ (#129759) 2024-07-31 02:09:20 +00:00
onnx_test_common.py [ONNX] Unify ONNXProgram and remove the old one (#136281) 2024-09-24 20:52:19 +00:00
pytorch_test_common.py [ONNX] Support FakeTensor in ONNXProgram (#135399) 2024-09-07 04:48:18 +00:00
test_autograd_funs.py
test_custom_ops.py Add None return type to init -- tests (#132352) 2024-08-01 15:44:51 +00:00
test_fx_passes.py Add None return type to init -- tests (#132352) 2024-08-01 15:44:51 +00:00
test_fx_to_onnx_decomp_skip.py [ONNX] Enable experimental exporter logic to dynamo_export and support refine dynamic_shapes (#134976) 2024-09-06 01:29:56 +00:00
test_fx_to_onnx.py [ONNX] Bump onnxscript in CI (#137497) 2024-10-08 21:56:30 +00:00
test_fx_type_promotion.py [ONNX] Run type promotion test in CI and update the table (#135915) 2024-09-16 16:46:13 +00:00
test_lazy_import.py [ONNX][DORT] Lazy-import onnxruntime (#134662) 2024-08-31 00:06:28 +00:00
test_models_onnxruntime.py [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
test_models_quantized_onnxruntime.py
test_models.py [BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ (#129759) 2024-07-31 02:09:20 +00:00
test_onnx_opset.py Add None return type to init -- tests (#132352) 2024-08-01 15:44:51 +00:00
test_onnxscript_no_runtime.py [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
test_onnxscript_runtime.py [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
test_op_consistency.py [BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ (#129759) 2024-07-31 02:09:20 +00:00
test_pytorch_jit_onnx.py
test_pytorch_onnx_no_runtime.py [ONNX] Remove deprecated export_to_pretty_string (#137790) 2024-10-21 18:17:48 +00:00
test_pytorch_onnx_onnxruntime_cuda.py Add None return type to init -- tests (#132352) 2024-08-01 15:44:51 +00:00
test_pytorch_onnx_onnxruntime.py [ONNX] Fix scaled_dot_product_attention with float scale (#135594) 2024-09-10 23:04:02 +00:00
test_pytorch_onnx_shape_inference.py [BE][Easy][8/19] enforce style for empty lines in import segments in test/[k-p]*/ (#129759) 2024-07-31 02:09:20 +00:00
test_symbolic_helper.py
test_utility_funs.py [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
test_verification.py [ONNX] Opt into ruff fmt (#134120) 2024-08-22 22:44:03 +00:00
verify.py [ONNX] Remove torch.onnx._export (#133824) 2024-08-20 20:54:48 +00:00