Skip to content

Conversation

justinchuby
Copy link
Collaborator

@justinchuby justinchuby commented Jul 30, 2025

Simplify implementation for aten_chunk and allow it to work on all data types.

Original author: @xadupre
Updated: Conditionally use the new implementation when torch>=2.7

@justinchuby justinchuby added the module: torchlib Related to the torch/aten function lib in development label Jul 30, 2025
Copy link

codecov bot commented Jul 30, 2025

❌ 11 Tests Failed:

Tests completed Failed Passed Skipped
13544 11 13533 2364
View the top 3 failed test(s) by shortest run time
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_0047_test_argmax_negative_axis_keepdims_random_select_last_index
Stack Traces | 0.004s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_argmax_negative_axis_keepdims_random_select_last_index'

The above exception was the direct cause of the following exception:
.nox\test_ort_nightly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_argmax_negative_axis_keepdims_random_select_last_index' (e=No module named 'tests.onnx_backend_test_code.test_argmax_negative_axis_keepdims_random_select_last_index') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_argmax_negative_axis_keepdims_random_select_last_index.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_argmax_negative_axis_keepdims_random_select_last_index.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import FLOAT, INT64
E   from onnxscript.onnx_opset import opset13
E   
E   @script()
E   def bck_test_argmax_negative_axis_keepdims_random_select_last_index(data: FLOAT[2,3,4]) -> (INT64[2,3,1]):
E       result = opset13.ArgMax(data, axis=-1, keepdims=1, select_last_index=1)
E       return result
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_0142_test_castlike_FLOAT16_to_DOUBLE
Stack Traces | 0.004s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_castlike_FLOAT16_to_DOUBLE'

The above exception was the direct cause of the following exception:
.nox\test_ort_nightly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_castlike_FLOAT16_to_DOUBLE' (e=No module named 'tests.onnx_backend_test_code.test_castlike_FLOAT16_to_DOUBLE') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_castlike_FLOAT16_to_DOUBLE.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_castlike_FLOAT16_to_DOUBLE.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import DOUBLE, FLOAT16
E   from onnxscript.onnx_opset import opset21
E   
E   @script()
E   def bck_test_castlike_FLOAT16_to_DOUBLE(input: FLOAT16[3,4], like: DOUBLE[1]) -> (DOUBLE[3,4]):
E       output = opset21.CastLike(input, like)
E       return output
onnxscript.backend.onnx_export_test.TestOnnxBackEnd::test_export2python_produces_correct_onnx_script_model_0348_test_clip_inbounds_expanded
Stack Traces | 0.004s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
C:\hostedtoolcache\windows\Python\3.11.9\x64\Lib\importlib\__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_clip_inbounds_expanded'

The above exception was the direct cause of the following exception:
.nox\test_torch_nightly\Lib\site-packages\parameterized\parameterized.py:620: in standalone_func
    return func(*(a + p.args), **p.kwargs, **kw)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:271: in test_export2python_produces_correct_onnx_script_model
    functions = extract_functions(backend_test.name, code, self.test_folder)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
onnxscript\backend\onnx_export_test.py:139: in extract_functions
    raise AssertionError(
E   AssertionError: Unable to import 'tests.onnx_backend_test_code.test_clip_inbounds_expanded' (e=No module named 'tests.onnx_backend_test_code.test_clip_inbounds_expanded') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_clip_inbounds_expanded.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_clip_inbounds_expanded.py', current folder: D:\a\onnxscript\onnxscript
E   ---- CONTENT --
E   import numpy
E   from onnx import TensorProto
E   from onnx.helper import make_tensor
E   from onnxscript import script, external_tensor
E   from onnxscript.values import Opset
E   from onnxscript.onnx_types import FLOAT
E   from onnxscript.onnx_opset import opset13
E   
E   @script()
E   def bck_test_clip_inbounds_expanded(x: FLOAT[3], min: FLOAT, max: FLOAT) -> (FLOAT[3]):
E       Clip_test_clip_inbounds_expanded_function_input_less_than_min = opset13.Less(x, min)
E       Clip_test_clip_inbounds_expanded_function_tmp = opset13.Where(Clip_test_clip_inbounds_expanded_function_input_less_than_min, min, x)
E       Clip_test_clip_inbounds_expanded_function_output_large_than_max = opset13.Less(max, Clip_test_clip_inbounds_expanded_function_tmp)
E       y = opset13.Where(Clip_test_clip_inbounds_expanded_function_output_large_than_max, max, Clip_test_clip_inbounds_expanded_function_tmp)
E       return y

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
@justinchuby justinchuby enabled auto-merge (squash) July 31, 2025 00:09
@titaiwangms titaiwangms removed their request for review July 31, 2025 00:51
@justinchuby justinchuby changed the title [torchlib] Improves aten_chunk conversion [torchlib] Improve aten_chunk conversion Jul 31, 2025
@justinchuby justinchuby requested a review from xadupre July 31, 2025 15:51
@justinchuby justinchuby merged commit da23d76 into main Jul 31, 2025
27 of 32 checks passed
@justinchuby justinchuby deleted the xadupre/split branch July 31, 2025 17:10
tadani3 pushed a commit to tadani3/onnxscript that referenced this pull request Aug 1, 2025
Simplify implementation for `aten_chunk` and allow it to work on all
data types.

Original author: @xadupre 
Updated: Conditionally use the new implementation when torch>=2.7

---------

Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Xavier Dupré <xadupre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: torchlib Related to the torch/aten function lib in development
Projects
Development

Successfully merging this pull request may close these issues.

2 participants