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

[draft] Xiaowu/fix bug(embedding bag) #1099

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

xiaowuhu
Copy link
Contributor

@xiaowuhu xiaowuhu commented Oct 23, 2023

from #1056 this, copy sample=7 data
we can got same result from test_embedding_bag_onnx() and test_embedding_bag_aten().

result from onnx-script:

[[ -7.426  -14.13    12.16    -3.05    -2.62  ]
 [  3.922   -7.277   -0.6943   1.091    2.855 ]]
[]
[0 0 0]
[0 0 0]

result from aten:

tensor([[ -7.4258, -14.1328,  12.1562,  -3.0508,  -2.6191],
        [  3.9219,  -7.2773,  -0.6943,   1.0908,   2.8555]],
       dtype=torch.float16)
tensor([], dtype=torch.int64)
tensor([0, 0, 0])
tensor([0, 0, 0])

@xiaowuhu xiaowuhu marked this pull request as draft October 23, 2023 08:52
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (10f9a1f) 78.55% compared to head (95a24dd) 56.93%.

Files Patch % Lines
onnxscript/function_libs/torch_lib/ops/core.py 42.10% 22 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1099       +/-   ##
===========================================
- Coverage   78.55%   56.93%   -21.63%     
===========================================
  Files         118      106       -12     
  Lines       15154    12752     -2402     
  Branches     1620     1331      -289     
===========================================
- Hits        11904     7260     -4644     
- Misses       2872     5189     +2317     
+ Partials      378      303       -75     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link

github-actions bot commented Oct 23, 2023

Test Results

       18 files  ±           0         18 suites  ±0   26m 13s ⏱️ - 37m 32s
  9 951 tests  -     1 236    8 107 ✔️  -      235  1 841 💤  -        951  0  -      53      3 🔥 +    3 
27 573 runs   - 132 429  23 324 ✔️  - 13 353  4 036 💤  - 117 246  0  - 2 043  213 🔥 +213 

For more details on these errors, see this check.

Results for commit 95a24dd. ± Comparison against base commit 10f9a1f.

This pull request removes 3639 and adds 2403 tests. Note that renamed tests count towards both.
docs.test.test_documentation_examples.TestDocumentationExample ‑ test_documentation_examples
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__add_batch_dimension
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__adjust_args_for_arange_int_dtype
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten__native_batch_norm_inference_functional_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten__native_batch_norm_training_functional_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_as_strided_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_convolution_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_cumsum_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_diagonal_bool_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_diagonal_onnx
…
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0000_test_layer_normalization_3d_axis2_epsilon
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0001_test_tril_neg
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0002_test_softsign
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0003_test_bitwise_not_3d
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0004_test_sqrt
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0005_test_averagepool_3d_default
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0006_test_castlike_FLOAT16_to_DOUBLE_expanded
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0007_test_averagepool_3d_dilations_small
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0007_test_reduce_min_default_axes_keepdims_random
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0008_test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
…
This pull request removes 1409 skipped tests and adds 459 skipped tests. Note that renamed tests count towards both.
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__add_batch_dimension
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_as_strided_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_convolution_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_cumsum_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_embedding_bag_1d_padding_idx_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_embedding_bag_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_linalg_vector_norm_no_dim_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_linalg_vector_norm_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_max_pool_onnx
onnxscript.function_libs.tools.torch_lib.deduce_type_constraints_test.TestDeduceTypeConstraints ‑ test_deduce_type_constraints_does_not_crash_for_onnx_function__aten_max_pool_with_indices_onnx
…
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0008_test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0009_test_cast_no_saturate_FLOAT_to_FLOAT8E4M3FN
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0013_test_reduce_max_bool_inputs
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0032_test_scan_sum
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0034_test_scan_sum
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0037_test_dft
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0039_test_castlike_FLOAT_to_FLOAT8E4M3FNUZ
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0039_test_dft
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0040_test_split_equal_parts_2d
onnxscript.backend.onnx_export_test.TestOnnxBackEnd ‑ test_export2python_produces_correct_onnx_script_model_0041_test_castlike_FLOAT_to_FLOAT8E4M3FNUZ
…

♻️ This comment has been updated with latest results.

print(max_indices)

def test_embedding_bag_aten():
import torch as t

Check notice

Code scanning / lintrunner

PYLINT/C0415 Note

Import outside toplevel (torch) (import-outside-toplevel)
See import-outside-toplevel. To disable, use # pylint: disable=import-outside-toplevel
print(max_indices)

def test_embedding_bag_nn_function():
import torch as t

Check notice

Code scanning / lintrunner

PYLINT/C0415 Note

Import outside toplevel (torch) (import-outside-toplevel)
See import-outside-toplevel. To disable, use # pylint: disable=import-outside-toplevel
[-4.2188, -4.2266, -2.7246, -6.8555, -7.6719]], dtype=t.float16)
indices = t.tensor([4, 9, 3, 0, 3], dtype=t.int64)
offsets = t.tensor([0, 3], dtype=t.int64)
mode = 0 # sum

Check warning

Code scanning / lintrunner

PYLINT/W0612 Warning

Unused variable 'mode' (unused-variable)
See unused-variable. To disable, use # pylint: disable=unused-variable
[-4.2188, -4.2266, -2.7246, -6.8555, -7.6719]], dtype=t.float16)
indices = t.tensor([4, 9, 3, 0, 3], dtype=t.int64)
offsets = t.tensor([0, 3], dtype=t.int64)
mode = 0 # sum

Check warning

Code scanning / lintrunner

RUFF/F841 Warning

Local variable mode is assigned to but never used.
See https://beta.ruff.rs/docs/rules/
[-4.2188, -4.2266, -2.7246, -6.8555, -7.6719]], dtype=t.float16)
indices = t.tensor([4, 9, 3, 0, 3], dtype=t.int64)
offsets = t.tensor([0, 3], dtype=t.int64)
mode = 0 # sum

Check notice

Code scanning / CodeQL

Unused local variable

Variable mode is not used.
@@ -3046,6 +3046,104 @@
return result, offset2bag, bag_size, max_indices



def test_embedding_bag_onnx():
import numpy as np

Check notice

Code scanning / lintrunner

PYLINT/C0415 Note

Import outside toplevel (numpy) (import-outside-toplevel)
See import-outside-toplevel. To disable, use # pylint: disable=import-outside-toplevel
# include_last_offset = True
per_sample_weights = np.array([2.4134, -0.1783, 7.1360, -0.7987, 2.3815], dtype=np.float16)
#per_sample_weights = np.array([-2.2930, 6.2148, 3.1562, 0.0791, 6.3555], dtype=np.float16)
result1, offset2bag, bag_size, max_indices = aten_embedding_bag(weight, indices, offsets, mode=mode, per_sample_weights=per_sample_weights)

Check warning

Code scanning / lintrunner

PYLINT/W0612 Warning

Unused variable 'offset2bag' (unused-variable)
See unused-variable. To disable, use # pylint: disable=unused-variable
# include_last_offset = True
per_sample_weights = np.array([2.4134, -0.1783, 7.1360, -0.7987, 2.3815], dtype=np.float16)
#per_sample_weights = np.array([-2.2930, 6.2148, 3.1562, 0.0791, 6.3555], dtype=np.float16)
result1, offset2bag, bag_size, max_indices = aten_embedding_bag(weight, indices, offsets, mode=mode, per_sample_weights=per_sample_weights)

Check warning

Code scanning / lintrunner

PYLINT/W0612 Warning

Unused variable 'bag_size' (unused-variable)
See unused-variable. To disable, use # pylint: disable=unused-variable
# include_last_offset = True
per_sample_weights = np.array([2.4134, -0.1783, 7.1360, -0.7987, 2.3815], dtype=np.float16)
#per_sample_weights = np.array([-2.2930, 6.2148, 3.1562, 0.0791, 6.3555], dtype=np.float16)
result1, offset2bag, bag_size, max_indices = aten_embedding_bag(weight, indices, offsets, mode=mode, per_sample_weights=per_sample_weights)

Check warning

Code scanning / lintrunner

PYLINT/W0612 Warning

Unused variable 'max_indices' (unused-variable)
See unused-variable. To disable, use # pylint: disable=unused-variable
#test_embedding_bag_aten()
#test_embedding_bag_nn_function()

exit(0)

Check notice

Code scanning / lintrunner

PYLINT/R1722 Note

Consider using 'sys.exit' instead (consider-using-sys-exit)
See consider-using-sys-exit. To disable, use # pylint: disable=consider-using-sys-exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant