onnxscript 0.7.2.dev20260904__tar.gz → 0.7.2.dev20260905__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 (203) hide show
  1. {onnxscript-0.7.2.dev20260904/onnxscript.egg-info → onnxscript-0.7.2.dev20260905}/PKG-INFO +2 -2
  2. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/core.py +126 -85
  3. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905/onnxscript.egg-info}/PKG-INFO +2 -2
  4. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/LICENSE +0 -0
  5. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/MANIFEST.in +0 -0
  6. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/README.md +0 -0
  7. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/VERSION +0 -0
  8. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/__init__.py +0 -0
  9. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/__init__.py +0 -0
  10. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_11.py +0 -0
  11. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_5.py +0 -0
  12. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_6.py +0 -0
  13. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_7.py +0 -0
  14. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_8.py +0 -0
  15. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_framework_apis/torch_2_9.py +0 -0
  16. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/__init__.py +0 -0
  17. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/_inference.py +0 -0
  18. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/_inliner.py +0 -0
  19. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/analysis.py +0 -0
  20. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/ast_utils.py +0 -0
  21. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/autocast.py +0 -0
  22. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/builder.py +0 -0
  23. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/converter.py +0 -0
  24. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/deprecation.py +0 -0
  25. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/evaluator.py +0 -0
  26. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/irbuilder.py +0 -0
  27. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/main.py +0 -0
  28. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/param_manipulation.py +0 -0
  29. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/sourceinfo.py +0 -0
  30. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/tape_builder.py +0 -0
  31. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/type_annotation.py +0 -0
  32. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/utils.py +0 -0
  33. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/values.py +0 -0
  34. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/_internal/version_utils.py +0 -0
  35. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/backend/__init__.py +0 -0
  36. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/backend/onnx_backend.py +0 -0
  37. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/backend/onnx_export.py +0 -0
  38. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/evaluator.py +0 -0
  39. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/tools/torch_lib/deduce_type_constraints.py +0 -0
  40. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/tools/torch_lib/generate_aten_signatures.py +0 -0
  41. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/tools/torch_lib/generate_prims_signatures.py +0 -0
  42. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/__init__.py +0 -0
  43. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/_constants.py +0 -0
  44. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/_flags.py +0 -0
  45. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/graph_building/__init__.py +0 -0
  46. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/__init__.py +0 -0
  47. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/common.py +0 -0
  48. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/fft.py +0 -0
  49. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/linalg.py +0 -0
  50. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/nested.py +0 -0
  51. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/nn.py +0 -0
  52. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/prims.py +0 -0
  53. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/quantized_decomposed.py +0 -0
  54. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/sparse.py +0 -0
  55. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/special.py +0 -0
  56. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/ops/vision.py +0 -0
  57. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/registration.py +0 -0
  58. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/function_libs/torch_lib/tensor_typing.py +0 -0
  59. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/ir/__init__.py +0 -0
  60. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/ir/_schemas.py +0 -0
  61. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/ir/convenience.py +0 -0
  62. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/ir/passes/__init__.py +0 -0
  63. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/ir/passes/common/__init__.py +0 -0
  64. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/nn/__init__.py +0 -0
  65. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/nn/_module.py +0 -0
  66. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/nn/_module_list.py +0 -0
  67. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/nn/_parameter.py +0 -0
  68. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/nn/_sequential.py +0 -0
  69. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/__init__.py +0 -0
  70. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset1.py +0 -0
  71. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset10.py +0 -0
  72. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset11.py +0 -0
  73. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset12.py +0 -0
  74. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset13.py +0 -0
  75. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset14.py +0 -0
  76. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset15.py +0 -0
  77. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset16.py +0 -0
  78. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset17.py +0 -0
  79. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset18.py +0 -0
  80. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset19.py +0 -0
  81. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset2.py +0 -0
  82. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset20.py +0 -0
  83. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset21.py +0 -0
  84. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset22.py +0 -0
  85. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset23.py +0 -0
  86. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset24.py +0 -0
  87. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset25.py +0 -0
  88. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset26.py +0 -0
  89. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset27.py +0 -0
  90. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset3.py +0 -0
  91. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset4.py +0 -0
  92. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset5.py +0 -0
  93. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset6.py +0 -0
  94. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset7.py +0 -0
  95. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset8.py +0 -0
  96. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset9.py +0 -0
  97. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_ml1.py +0 -0
  98. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_ml2.py +0 -0
  99. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_ml3.py +0 -0
  100. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_ml4.py +0 -0
  101. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_ml5.py +0 -0
  102. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_opset/_impl/opset_ai_onnx_preview1.py +0 -0
  103. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/onnx_types.py +0 -0
  104. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/optimizer/__init__.py +0 -0
  105. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/optimizer/_constant_folding.py +0 -0
  106. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/optimizer/_optimizer.py +0 -0
  107. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/py.typed +0 -0
  108. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/__init__.py +0 -0
  109. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_basics.py +0 -0
  110. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_context.py +0 -0
  111. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_fusion_utils.py +0 -0
  112. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_ir_utils.py +0 -0
  113. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_matcher.py +0 -0
  114. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_pattern_ir.py +0 -0
  115. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/_rewrite_rule.py +0 -0
  116. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_bart_encoder.py +0 -0
  117. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_phi2lm.py +0 -0
  118. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_phi4lm.py +0 -0
  119. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_rotary_embedding_models.py +0 -0
  120. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_smollm_1.py +0 -0
  121. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_smollm_2.py +0 -0
  122. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_test_models.py +0 -0
  123. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_whisper_decoder.py +0 -0
  124. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/models/_whisper_encoder.py +0 -0
  125. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/onnx_fusions/__init__.py +0 -0
  126. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/onnx_fusions/_onnx_fusions.py +0 -0
  127. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/onnxruntime/__init__.py +0 -0
  128. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/onnxruntime/bfloat16_utils/bfloat16_converter.py +0 -0
  129. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/__init__.py +0 -0
  130. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/_core.py +0 -0
  131. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/_test_utils.py +0 -0
  132. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/attention.py +0 -0
  133. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/bias_gelu.py +0 -0
  134. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/cos_sin_cache.py +0 -0
  135. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/erfgelu.py +0 -0
  136. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/fused_matmul_rule_sets.py +0 -0
  137. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/gelu.py +0 -0
  138. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/gqa.py +0 -0
  139. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/gqa_packed_qkv.py +0 -0
  140. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/group_normalization_merge_silu.py +0 -0
  141. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/instance_to_group_normalization.py +0 -0
  142. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/mha.py +0 -0
  143. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/mha_bias.py +0 -0
  144. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/mha_scale.py +0 -0
  145. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/rms_normalization.py +0 -0
  146. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/rotary_embedding.py +0 -0
  147. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/sdpa.py +0 -0
  148. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/sdpa_via_mha.py +0 -0
  149. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/shape_optimization.py +0 -0
  150. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/skip_normalization.py +0 -0
  151. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/ort_fusions/softmax.py +0 -0
  152. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/pattern.py +0 -0
  153. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/__init__.py +0 -0
  154. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/__init__.py +0 -0
  155. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_basic_rules.py +0 -0
  156. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_broadcast_to_matmul.py +0 -0
  157. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_cast_constant_of_shape.py +0 -0
  158. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_collapse_slices.py +0 -0
  159. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_fuse_batchnorm.py +0 -0
  160. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_fuse_conv_affine.py +0 -0
  161. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_fuse_hardswish.py +0 -0
  162. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_fuse_pad_into_conv.py +0 -0
  163. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_fuse_relus_clips.py +0 -0
  164. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_gemm_to_matmul_add.py +0 -0
  165. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_materialize_reshape_shape.py +0 -0
  166. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_matmul_add_to_gemm.py +0 -0
  167. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_min_max_to_clip.py +0 -0
  168. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_no_op.py +0 -0
  169. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_redundant_scatter_nd.py +0 -0
  170. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_remove_expand_before_binary_op.py +0 -0
  171. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/common/_remove_optional_bias.py +0 -0
  172. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/fusion/__init__.py +0 -0
  173. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/fusion/_gqa.py +0 -0
  174. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/fusion/_layer_norm.py +0 -0
  175. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/fusion/_rms_normalization.py +0 -0
  176. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/rules/fusion/_rotary_embedding.py +0 -0
  177. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/rewriter/testing.py +0 -0
  178. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tensor.py +0 -0
  179. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/testing/__init__.py +0 -0
  180. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/__init__.py +0 -0
  181. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/memory_peak.py +0 -0
  182. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/transformers_models/__init__.py +0 -0
  183. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/transformers_models/llama.py +0 -0
  184. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/transformers_models/mistral.py +0 -0
  185. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/transformers_models/phi.py +0 -0
  186. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/tools/transformers_models/phi3.py +0 -0
  187. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/__init__.py +0 -0
  188. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/evaluation_utils.py +0 -0
  189. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/metadata_merger.py +0 -0
  190. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/replace.py +0 -0
  191. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/timing_utils.py +0 -0
  192. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/utils/utils.py +0 -0
  193. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/values.py +0 -0
  194. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/version_converter/__init__.py +0 -0
  195. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/version_converter/_c_api_utils.py +0 -0
  196. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript/version_converter/_version_converter.py +0 -0
  197. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript.egg-info/SOURCES.txt +0 -0
  198. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript.egg-info/dependency_links.txt +0 -0
  199. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript.egg-info/requires.txt +0 -0
  200. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/onnxscript.egg-info/top_level.txt +0 -0
  201. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/pyproject.toml +0 -0
  202. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/setup.cfg +0 -0
  203. {onnxscript-0.7.2.dev20260904 → onnxscript-0.7.2.dev20260905}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onnxscript
3
- Version: 0.7.2.dev20260904
3
+ Version: 0.7.2.dev20260905
4
4
  Summary: Naturally author ONNX functions and models using a subset of Python
5
5
  Author-email: Microsoft Corporation <onnx@microsoft.com>
6
6
  License: MIT License
@@ -27,7 +27,7 @@ License: MIT License
27
27
 
28
28
  Project-URL: Homepage, https://microsoft.github.io/onnxscript/
29
29
  Project-URL: Repository, https://github.com/microsoft/onnxscript
30
- Project-URL: Commit, https://github.com/microsoft/onnxscript/tree/9709f8a0777037c4c0a6320a64593f342aef7183
30
+ Project-URL: Commit, https://github.com/microsoft/onnxscript/tree/d1c005d158f40020597a0b35fd681c4f5286378f
31
31
  Classifier: Development Status :: 4 - Beta
32
32
  Classifier: Environment :: Console
33
33
  Classifier: Intended Audience :: Developers
@@ -57,6 +57,7 @@ _INT32_MAX = 2147483647
57
57
  _INT64_MAX = 9223372036854775807
58
58
  _INT64_MIN = -9223372036854775808
59
59
  _MATH_PI = math.pi
60
+ _AS_STRIDED_STATIC_INDEX_SIZE_LIMIT = 512 * 512
60
61
 
61
62
 
62
63
  @functools.lru_cache(maxsize=None)
@@ -900,76 +901,92 @@ def aten_argwhere(self: TensorType) -> TensorType:
900
901
 
901
902
  @torch_op("aten::as_strided", trace_only=True)
902
903
  def aten_as_strided(
903
- self: TTensor, size: INT64, stride: Sequence[int], storage_offset: int = 0
904
+ self: TTensor,
905
+ size: Sequence[INT64],
906
+ stride: Sequence[INT64],
907
+ storage_offset: Optional[INT64] = None,
904
908
  ) -> TTensor:
905
909
  """as_strided(Tensor(a) self, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor(a)"""
906
910
 
907
- rank = len(stride)
908
- return _aten_as_strided_onnx(self, size, stride, storage_offset, rank)
909
-
910
-
911
- @torch_op("aten::as_strided", private=True)
912
- def _aten_as_strided_onnx(
913
- self: TTensor, size: INT64, stride: INT64, storage_offset: int = 0, rank: int = 0
914
- ) -> TTensor:
915
- # e.g. when size=[2,3,4], stride=[2,1,3], indices=[0]
916
- # i = 0
917
- # indices=[0], add_value=[0,3,6,9]
918
- # expand(shape=[4]) to [0,0,0,0]
919
- # then + add_value = [0,3,6,9]
920
- # i = 1
921
- # indices=[0,3,6,9], add_value=[0,1,2]
922
- # expand(shape=[3,4] to [[0,3,6,9],[0,3,6,9],[0,3,6,9]]
923
- # indices + add_value = [[0,3,6,9],[1,3,7,10],[2,5,8,11]]
924
- # i = 2
925
- # indices = [[0,3,6,9],[1,3,7,10],[2,5,8,11]], add_value=[0,2]
926
- # expand(shape=[2,3,4]) to [[[0,3,6,9],[1,3,7,10],[2,5,8,11]]],[[0,3,6,9],[1,3,7,10],[2,5,8,11]]]
927
- # indices + add_value = [[[0,3,6,9],[1,3,7,10],[2,5,8,11]]],[[2,5,8,11],[3,5,9,12],[4,7,10,13]]]
928
- neg_1 = op.Constant(value_ints=[-1])
929
- rank_tensor = op.Reshape(rank, neg_1) # should be 3
930
- # The final indices for op.Gather(data, indices), will be continually changed during the loop
931
- indices = op.Constant(value_int=0)
932
- one_seq = op.SequenceEmpty()
933
- for i in range(rank):
934
- # Get the index from back to front, should be 2,1,0 when to i=0,1,2
935
- j = rank - i - 1
936
- j_tensor = op.Reshape(j, neg_1)
937
- # Get size according to index_j, should be 4,3,2 when i=0,1,2
938
- size_dim_j = op.Gather(size, j_tensor, axis=0)
939
- # Get right size according to index_j, should be [4],[3,4],[2,3,4] when i=0,1,2
940
- size_after_j = op.Slice(size, j_tensor, rank_tensor)
941
- # Get stride according to index_j, should be 3,1,2 when i=0,1,2
942
- stride_dim_j = op.Gather(stride, j_tensor, axis=0)
943
- indices = op.Expand(indices, size_after_j)
944
- # When size[j]=4, stride[j]=3, then add_value = [0,1,2,3] * 3 = [0,3,6,9]
945
- # When size[j]=3, stride[j]=1, then add_value = [0,1,2] * 1 = [0,1,2]
946
- # When size[j]=2, stride[j]=2, then add_value = [0,1] * 2 = [0,2]
947
- add_value = op.Range(0, size_dim_j, 1) * stride_dim_j
948
- # Compute the shape for add_value for correct broadcasting
949
- if i == 0:
950
- # shape = [dim_size]
951
- shape = size_dim_j
952
- else:
953
- # shape = [dim_size, 1, 1, ...], the count of 1 euqal to i
954
- ones = op.ConcatFromSequence(one_seq, axis=0)
955
- shape = op.Concat(op.Cast(size_dim_j, to=FLOAT.dtype), ones, axis=0)
956
- shape = op.Cast(shape, to=INT64.dtype)
957
-
958
- add_value = op.Reshape(add_value, shape)
959
- # Broadcasting add value to indices according to size and stride value
960
- indices = indices + add_value
961
- # Dims after dim_size to reshape(add_value), should be [1],[1,1],[1,1,1] when i=0,1,2
962
- one_seq = op.SequenceInsert(one_seq, op.Constant(value_floats=[1.0]))
963
-
911
+ # torch.as_strided produces a view of `self`'s underlying linear storage
912
+ # with the requested `size` (the output shape) and `stride` (the step, in
913
+ # elements of storage, taken along each output dimension), starting at
914
+ # `storage_offset` elements into the storage. For an output element at
915
+ # position (i_0, ..., i_{n-1}) the element read from storage lives at the flat
916
+ # index storage_offset + sum_d i_d * stride[d]. So if we flatten `self` to 1-D
917
+ # and gather it with a tensor of those flat indices shaped like the output, we
918
+ # reproduce the view as a single Gather. This avoids the hard-to-fold loop of
919
+ # the previous implementation.
920
+ rank = len(size)
921
+ # ONNX exposes logical values, not backing storage. Flattening is correct only
922
+ # when logical row-major order matches storage order; non-contiguous views remain
923
+ # unsupported, as they were in the previous lowering.
964
924
  self_flatten = op.Reshape(self, op.Constant(value_ints=[-1]))
965
- indices = op.Add(indices, storage_offset)
966
- result = op.Gather(self_flatten, indices)
967
925
 
968
- return result
926
+ # A missing storage_offset means "start at the beginning of the storage".
927
+ if storage_offset is None:
928
+ storage_offset = 0
929
+
930
+ static_inputs = (
931
+ all(isinstance(s, int) for s in size)
932
+ and all(isinstance(s, int) for s in stride)
933
+ and isinstance(storage_offset, int)
934
+ )
935
+ static_index_count = math.prod(size) if static_inputs else None
936
+ if (
937
+ static_index_count is not None
938
+ and static_index_count <= _AS_STRIDED_STATIC_INDEX_SIZE_LIMIT
939
+ ):
940
+ # Static fast path: every size/stride/offset is known at trace time, so we
941
+ # compute the full index tensor with NumPy and emit it as a single
942
+ # constant that downstream passes can fold trivially.
943
+ # Start from the storage_offset; the per-dimension contributions are added in.
944
+ indices = np.array(storage_offset, dtype=np.int64)
945
+ for dim, (dim_size, dim_stride) in enumerate(zip(size, stride)):
946
+ # Contribution of dimension `dim`: index i_dim contributes i_dim * stride[dim].
947
+ add_value = np.arange(dim_size, dtype=np.int64) * dim_stride
948
+ # Reshape that 1-D contribution so it broadcasts along `dim` only
949
+ # (length dim_size at position `dim`, length 1 everywhere else), which
950
+ # lets the running sum build the full n-D index grid.
951
+ broadcast_shape = [1] * rank
952
+ broadcast_shape[dim] = dim_size
953
+ indices = indices + add_value.reshape(broadcast_shape)
954
+ indices = op.Constant(value=ir.tensor(indices))
955
+ else:
956
+ # Build runtime indices when a SymInt is dynamic or a static index tensor
957
+ # would exceed the optimizer's default folded-output size limit. The loop
958
+ # is unrolled at trace time because rank is static, so no Loop/Scan is emitted.
959
+ zero = op.Constant(value_int=0)
960
+ one = op.Constant(value_int=1)
961
+ # `scalar_shape` reshapes a value to a 0-D scalar (shape []).
962
+ scalar_shape = op.Constant(value=ir.tensor(np.array([], dtype=np.int64)))
963
+ # Start the running index from storage_offset as an INT64 scalar; SymInt
964
+ # runtime values are assumed to be INT64.
965
+ indices = op.Reshape(storage_offset, scalar_shape)
966
+ for dim in range(rank):
967
+ # Reshape this dimension's size and stride to INT64 scalars.
968
+ dim_size = op.Reshape(size[dim], scalar_shape)
969
+ dim_stride = op.Reshape(stride[dim], scalar_shape)
970
+ # add_value = arange(dim_size) * dim_stride, a 1-D tensor of length dim_size
971
+ # holding the storage offsets contributed by index 0..dim_size-1 along `dim`.
972
+ add_value = op.Mul(op.Range(zero, dim_size, one), dim_stride)
973
+ # Insert singleton axes everywhere except `dim` so this 1-D contribution
974
+ # broadcasts along dimension `dim` only when added to the running index,
975
+ # matching the NumPy `reshape(broadcast_shape)` in the static path.
976
+ unsqueeze_axes = [axis for axis in range(rank) if axis != dim]
977
+ if unsqueeze_axes:
978
+ add_value = op.Unsqueeze(add_value, op.Constant(value_ints=unsqueeze_axes))
979
+ indices = op.Add(indices, add_value)
980
+
981
+ # `indices` now has shape `size`; gathering yields the strided view.
982
+ return op.Gather(self_flatten, indices)
969
983
 
970
984
 
971
985
  def aten_as_strided_copy(
972
- self: TensorType, size: INT64, stride: INT64, storage_offset: Optional[INT64] = None
986
+ self: TensorType,
987
+ size: Sequence[INT64],
988
+ stride: Sequence[INT64],
989
+ storage_offset: Optional[INT64] = None,
973
990
  ) -> TensorType:
974
991
  """as_strided_copy(Tensor self, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor"""
975
992
 
@@ -979,8 +996,8 @@ def aten_as_strided_copy(
979
996
  def aten_as_strided_scatter(
980
997
  self: TensorType,
981
998
  src: TensorType,
982
- size: INT64,
983
- stride: INT64,
999
+ size: Sequence[INT64],
1000
+ stride: Sequence[INT64],
984
1001
  storage_offset: Optional[INT64] = None,
985
1002
  ) -> TensorType:
986
1003
  """as_strided_scatter(Tensor self, Tensor src, SymInt[] size, SymInt[] stride, SymInt? storage_offset=None) -> Tensor"""
@@ -3724,7 +3741,7 @@ def aten_empty_quantized(
3724
3741
  @torch_op("aten::empty_strided", trace_only=True)
3725
3742
  def aten_empty_strided(
3726
3743
  size: Sequence[INT64],
3727
- stride: INT64,
3744
+ stride: Sequence[INT64],
3728
3745
  layout: str = "",
3729
3746
  dtype: int = FLOAT.dtype,
3730
3747
  device: str = "",
@@ -7581,8 +7598,8 @@ def aten_new_empty(
7581
7598
  @torch_op("aten::new_empty_strided", trace_only=True)
7582
7599
  def aten_new_empty_strided(
7583
7600
  self: TTensor,
7584
- size: INT64,
7585
- stride: INT64,
7601
+ size: Sequence[INT64],
7602
+ stride: Sequence[INT64],
7586
7603
  dtype: int = -1,
7587
7604
  layout: str = "",
7588
7605
  device: str = "",
@@ -7591,6 +7608,7 @@ def aten_new_empty_strided(
7591
7608
  """new_empty_strided(Tensor self, SymInt[] size, SymInt[] stride, *, ScalarType? dtype=None, Layout? layout=None, Device? device=None, bool? pin_memory=None) -> Tensor"""
7592
7609
 
7593
7610
  # using zero to simulate empty array
7611
+ size = common_ops.merge_dims(size)
7594
7612
  zero = op.ConstantOfShape(size)
7595
7613
  if dtype == -1:
7596
7614
  return op.CastLike(zero, self)
@@ -8772,7 +8790,9 @@ def aten_roll(self: TTensor, shifts: Sequence[int], dims: Sequence[int] = ()) ->
8772
8790
  self_rank = len(self.shape)
8773
8791
  if self_rank == 0:
8774
8792
  return op.Identity(self)
8775
- elif self.shape[0] == 0: # empty tensor
8793
+ elif 0 in self.shape:
8794
+ # A tensor with no elements rolls to itself, which is what torch returns. It is
8795
+ # also what keeps a zero length out of the modulo in the helpers below.
8776
8796
  return op.Identity(self)
8777
8797
 
8778
8798
  # NOTE: In pytorch, default value of dims is an empty list.
@@ -8784,6 +8804,9 @@ def aten_roll(self: TTensor, shifts: Sequence[int], dims: Sequence[int] = ()) ->
8784
8804
  result = self
8785
8805
  for i, shift in enumerate(shifts):
8786
8806
  dim = dims[i]
8807
+ # PyTorch accepts negative dim as reversed counting
8808
+ if dim < 0:
8809
+ dim = self_rank + dim
8787
8810
  result = _aten_roll_shift_and_dim_onnx(result, shift, dim)
8788
8811
  return result
8789
8812
 
@@ -8804,7 +8827,10 @@ def aten_roll_complex(
8804
8827
  if self_rank == 1:
8805
8828
  return op.Identity(self)
8806
8829
 
8807
- if self.shape[0] == 0: # empty tensor
8830
+ if 0 in self.shape:
8831
+ # Same as aten_roll: a tensor with no elements rolls to itself. The trailing
8832
+ # dimension that carries the real and imaginary parts is never zero, so this
8833
+ # only ever sees a dimension torch can see.
8808
8834
  return op.Identity(self)
8809
8835
 
8810
8836
  self_real = op.Slice(self, [0], [1], axes=[-1])
@@ -8819,6 +8845,9 @@ def aten_roll_complex(
8819
8845
  else:
8820
8846
  assert len(shifts) == len(dims)
8821
8847
  for i, dim in enumerate(dims):
8848
+ if dim < 0:
8849
+ # Account for the complex dimension in ONNX
8850
+ dim = self_rank + dim - 1
8822
8851
  self_real = _aten_roll_shift_and_dim_onnx(self_real, shifts[i], dim)
8823
8852
  self_imag = _aten_roll_shift_and_dim_onnx(self_imag, shifts[i], dim)
8824
8853
 
@@ -8827,36 +8856,48 @@ def aten_roll_complex(
8827
8856
 
8828
8857
 
8829
8858
  def _aten_roll_shift_no_dim_onnx(self: TTensor, shift: int) -> TTensor:
8859
+ # The element count is the divisor of the Mod below, and Mod by zero is undefined in
8860
+ # ONNX. Both callers return a tensor with no elements unchanged before reaching here.
8861
+ assert self.shape is None or 0 not in self.shape, (
8862
+ "the element count must not be zero because Mod by zero is undefined"
8863
+ )
8864
+
8830
8865
  neg_1 = op.Constant(value_ints=[-1])
8831
8866
  # flatten the self tensor: from [[A,B],[C,D]] to [A,B,C,D]
8832
8867
  self_flatten = op.Reshape(self, neg_1)
8833
- # Compute slice length
8834
- if shift < 0:
8835
- # For [A,B,C,D], if shift is -1, slice_length = -(-1) = 1, means move [A] to the end
8836
- slice_length = op.Constant(value_ints=[-shift])
8837
- else:
8838
- # For [A,B,C,D], if shift is 1, slice_length = 4 - 1 = 3, means move [A,B,C] to the end
8839
- # The effect equals to move [D] to the beginning
8840
- slice_length = op.Size(self_flatten) - op.Constant(value_ints=[shift])
8868
+ total_length = op.Shape(self_flatten)
8869
+ # Compute slice length. roll is circular, so the shift is taken modulo the number
8870
+ # of elements. For [A,B,C,D], if shift is 1, slice_length = 3, means move [A,B,C]
8871
+ # to the end. The effect equals to move [D] to the beginning.
8872
+ slice_length = op.Mod(op.Constant(value_ints=[-shift]), total_length)
8841
8873
  # Get second part of the tensor, e.g. [A,B,C]
8842
8874
  suffix = op.Slice(self_flatten, op.Constant(value_ints=[0]), slice_length)
8843
8875
  # Get first part of the tensor, e.g. [D]
8844
- prefix = op.Slice(self_flatten, slice_length, op.Reshape(op.Size(self_flatten), neg_1))
8876
+ prefix = op.Slice(self_flatten, slice_length, total_length)
8845
8877
  # Concat first+second together, e.g. [D,A,B,C]
8846
8878
  result = op.Concat(prefix, suffix, axis=0)
8847
- return op.Reshape(result, op.Shape(self))
8879
+ # allowzero so a dimension that is only zero at run time stays zero here, rather than
8880
+ # being read as "copy the input dimension" against a flattened tensor.
8881
+ return op.Reshape(result, op.Shape(self), allowzero=True)
8848
8882
 
8849
8883
 
8850
8884
  def _aten_roll_shift_and_dim_onnx(self: TTensor, shift: int, dim: int) -> TTensor:
8851
- neg_1 = op.Constant(value_ints=[-1])
8885
+ # dim must already be normalized to a nonnegative axis, because Shape below
8886
+ # reads an empty range when start is negative and end is zero.
8887
+ # The length of that dimension is the divisor of the Mod below, and Mod by zero is
8888
+ # undefined in ONNX. Both callers return a tensor with no elements unchanged before
8889
+ # reaching here.
8890
+ assert self.shape is None or self.shape[dim] != 0, (
8891
+ "the dimension length must not be zero because Mod by zero is undefined"
8892
+ )
8893
+
8852
8894
  dim_tensor = op.Constant(value_ints=[dim])
8853
- if shift < 0:
8854
- slice_length = op.Constant(value_ints=[-shift])
8855
- else:
8856
- slice_length = op.Shape(self, start=dim, end=dim + 1) - op.Constant(value_ints=[shift])
8895
+ dim_length = op.Shape(self, start=dim, end=dim + 1)
8896
+ # roll is circular, so the shift is taken modulo the length of the dimension
8897
+ slice_length = op.Mod(op.Constant(value_ints=[-shift]), dim_length)
8857
8898
  # from [A,B,C,D] -> [D,A,B,C], [D] is prefix, [A,B,C] is suffix
8858
8899
  suffix = op.Slice(self, op.Constant(value_ints=[0]), slice_length, axes=dim_tensor)
8859
- prefix = op.Slice(self, slice_length, op.Reshape(op.Size(self), neg_1), axes=dim_tensor)
8900
+ prefix = op.Slice(self, slice_length, dim_length, axes=dim_tensor)
8860
8901
  result = op.Concat(prefix, suffix, axis=dim)
8861
8902
  return result
8862
8903
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onnxscript
3
- Version: 0.7.2.dev20260904
3
+ Version: 0.7.2.dev20260905
4
4
  Summary: Naturally author ONNX functions and models using a subset of Python
5
5
  Author-email: Microsoft Corporation <onnx@microsoft.com>
6
6
  License: MIT License
@@ -27,7 +27,7 @@ License: MIT License
27
27
 
28
28
  Project-URL: Homepage, https://microsoft.github.io/onnxscript/
29
29
  Project-URL: Repository, https://github.com/microsoft/onnxscript
30
- Project-URL: Commit, https://github.com/microsoft/onnxscript/tree/9709f8a0777037c4c0a6320a64593f342aef7183
30
+ Project-URL: Commit, https://github.com/microsoft/onnxscript/tree/d1c005d158f40020597a0b35fd681c4f5286378f
31
31
  Classifier: Development Status :: 4 - Beta
32
32
  Classifier: Environment :: Console
33
33
  Classifier: Intended Audience :: Developers