Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test cases for pattern matching against optional inputs #1890

Merged
merged 5 commits into from
Oct 2, 2024

Conversation

gramalingam
Copy link
Collaborator

I updated the pattern matcher to support matching against optional inputs. The change was accidentally pushed into the main branch (not a sub-branch as I thought) ... guess the branch protections were not good enough, changed it now.

Adding test-cases now to test it in this PR.

Copy link

codecov bot commented Oct 2, 2024

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
13138 3 13135 2641
View the top 3 failed tests by shortest run time
onnxscript.backend.onnx_export_test.TestOnnxBackEnd test_export2python_produces_correct_onnx_script_model_1219_test_thresholdedrelu_example
Stack Traces | 0.003s run time
onnxscript\backend\onnx_export_test.py:137: in extract_functions
    mod = importlib.import_module(import_name)
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\importlib\__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_thresholdedrelu_example'

The above exception was the direct cause of the following exception:
.nox\test\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_thresholdedrelu_example' (e=No module named 'tests.onnx_backend_test_code.test_thresholdedrelu_example') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_thresholdedrelu_example.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_thresholdedrelu_example.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 opset10
E   
E   @script()
E   def bck_test_thresholdedrelu_example(x: FLOAT[5]) -> (FLOAT[5]):
E       y = opset10.ThresholdedRelu(x, alpha=2.0)
E       return y
onnxscript.backend.onnx_export_test.TestOnnxBackEnd test_export2python_produces_correct_onnx_script_model_0468_test_hardswish
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.9.13\x64\lib\importlib\__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_hardswish'

The above exception was the direct cause of the following exception:
.nox\test\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_hardswish' (e=No module named 'tests.onnx_backend_test_code.test_hardswish') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_hardswish.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_hardswish.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 opset14
E   
E   @script()
E   def bck_test_hardswish(x: FLOAT[3,4,5]) -> (FLOAT[3,4,5]):
E       y = opset14.HardSwish(x)
E       return y
onnxscript.backend.onnx_export_test.TestOnnxBackEnd test_export2python_produces_correct_onnx_script_model_0956_test_resize_downsample_sizes_linear_pytorch_half_pixel
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.9.13\x64\lib\importlib\__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
E   ModuleNotFoundError: No module named 'tests.onnx_backend_test_code.test_resize_downsample_sizes_linear_pytorch_half_pixel'

The above exception was the direct cause of the following exception:
.nox\test\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_resize_downsample_sizes_linear_pytorch_half_pixel' (e=No module named 'tests.onnx_backend_test_code.test_resize_downsample_sizes_linear_pytorch_half_pixel') (file: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_resize_downsample_sizes_linear_pytorch_half_pixel.py', absolute path: 'D:\\a\\onnxscript\\onnxscript\\tests\\onnx_backend_test_code\\test_resize_downsample_sizes_linear_pytorch_half_pixel.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 opset19
E   
E   @script()
E   def bck_test_resize_downsample_sizes_linear_pytorch_half_pixel(X: FLOAT[1,1,4,4], sizes: INT64[4]) -> (FLOAT[1,1,3,1]):
E       Y = opset19.Resize(X, None, None, sizes, coordinate_transformation_mode='pytorch_half_pixel', mode='linear')
E       return Y

To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
@gramalingam gramalingam enabled auto-merge (squash) October 2, 2024 22:07
@gramalingam gramalingam merged commit 35fdcf5 into main Oct 2, 2024
28 of 39 checks passed
@gramalingam gramalingam deleted the rama/rewrite-none branch October 2, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants