已合并
[onnx] fix group_norm_silu and rotary_mul onnx api. #31963
shi-jiaxin9创建于 3月18日
[onnx] fix group_norm_silu and rotary_mul onnx api. #31963
已合并
共 5 个文件变更+152-18
| @@ -1,6 +1,7 @@ | |||
| 1 | import os | 1 | import os |
| 2 | import shutil | 2 | import shutil |
| 3 | import math | 3 | import math |
| 4 | +import unittest | ||
| 4 | 5 | ||
| 5 | import torch | 6 | import torch |
| 6 | from torch.nn.parameter import Parameter | 7 | from torch.nn.parameter import Parameter |
| @@ -533,6 +534,7 @@ class TestOnnxOps(TestCase): | |||
| 533 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 534 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 534 | onnx_model_name))) | 535 | onnx_model_name))) |
| 535 | 536 | ||
| 537 | + | ||
| 536 | def test_wrapper_npu_fused_attention_layernorm_qkv_fwd(self): | 538 | def test_wrapper_npu_fused_attention_layernorm_qkv_fwd(self): |
| 537 | class Model(torch.nn.Module): | 539 | class Model(torch.nn.Module): |
| 538 | def __init__(self): | 540 | def __init__(self): |
| @@ -45,6 +45,7 @@ class TestOnnxOps(TestCase): | |||
| 45 | input_names=input_names, | 45 | input_names=input_names, |
| 46 | output_names=output_names) | 46 | output_names=output_names) |
| 47 | 47 | ||
| 48 | + | ||
| 48 | def test_wrapper_npu_one_hot(self): | 49 | def test_wrapper_npu_one_hot(self): |
| 49 | class Model(torch.nn.Module): | 50 | class Model(torch.nn.Module): |
| 50 | def __init__(self): | 51 | def __init__(self): |
| @@ -65,6 +66,7 @@ class TestOnnxOps(TestCase): | |||
| 65 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 66 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 66 | onnx_model_name))) | 67 | onnx_model_name))) |
| 67 | 68 | ||
| 69 | + | ||
| 68 | def test_wrapper_npu_slice(self): | 70 | def test_wrapper_npu_slice(self): |
| 69 | class Model(torch.nn.Module): | 71 | class Model(torch.nn.Module): |
| 70 | def __init__(self): | 72 | def __init__(self): |
| @@ -86,6 +88,7 @@ class TestOnnxOps(TestCase): | |||
| 86 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 88 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 87 | onnx_model_name))) | 89 | onnx_model_name))) |
| 88 | 90 | ||
| 91 | + | ||
| 89 | def test_wrapper_npu_roi_align(self): | 92 | def test_wrapper_npu_roi_align(self): |
| 90 | class Model(torch.nn.Module): | 93 | class Model(torch.nn.Module): |
| 91 | def __init__(self): | 94 | def __init__(self): |
| @@ -112,6 +115,7 @@ class TestOnnxOps(TestCase): | |||
| 112 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 115 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 113 | onnx_model_name))) | 116 | onnx_model_name))) |
| 114 | 117 | ||
| 118 | + | ||
| 115 | def test_wrapper_npu_iou(self): | 119 | def test_wrapper_npu_iou(self): |
| 116 | class Model(torch.nn.Module): | 120 | class Model(torch.nn.Module): |
| 117 | def __init__(self): | 121 | def __init__(self): |
| @@ -163,6 +167,7 @@ class TestOnnxOps(TestCase): | |||
| 163 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 167 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 164 | onnx_model_name))) | 168 | onnx_model_name))) |
| 165 | 169 | ||
| 170 | + | ||
| 166 | def test_wrapper_npu_fast_gelu(self): | 171 | def test_wrapper_npu_fast_gelu(self): |
| 167 | class Model(torch.nn.Module): | 172 | class Model(torch.nn.Module): |
| 168 | def __init__(self): | 173 | def __init__(self): |
| @@ -183,6 +188,7 @@ class TestOnnxOps(TestCase): | |||
| 183 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 188 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 184 | onnx_model_name))) | 189 | onnx_model_name))) |
| 185 | 190 | ||
| 191 | + | ||
| 186 | 192 | ||
| 187 | def test_wrapper_npu_geglu(self): | 193 | def test_wrapper_npu_geglu(self): |
| 188 | class Model(torch.nn.Module): | 194 | class Model(torch.nn.Module): |
| @@ -203,6 +209,7 @@ class TestOnnxOps(TestCase): | |||
| 203 | assert(os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 209 | assert(os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 204 | onnx_model_name))) | 210 | onnx_model_name))) |
| 205 | 211 | ||
| 212 | + | ||
| 206 | def test_wrapper_npu_multi_head_attention(self): | 213 | def test_wrapper_npu_multi_head_attention(self): |
| 207 | class Model(torch.nn.Module): | 214 | class Model(torch.nn.Module): |
| 208 | def __init__(self): | 215 | def __init__(self): |
| @@ -292,6 +299,7 @@ class TestOnnxOps(TestCase): | |||
| 292 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 299 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 293 | onnx_model_name))) | 300 | onnx_model_name))) |
| 294 | 301 | ||
| 302 | + | ||
| 295 | def test_wrapper_npu_diou(self): | 303 | def test_wrapper_npu_diou(self): |
| 296 | class Model(torch.nn.Module): | 304 | class Model(torch.nn.Module): |
| 297 | def __init__(self): | 305 | def __init__(self): |
| @@ -318,6 +326,7 @@ class TestOnnxOps(TestCase): | |||
| 318 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 326 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 319 | onnx_model_name))) | 327 | onnx_model_name))) |
| 320 | 328 | ||
| 329 | + | ||
| 321 | def test_wrapper_npu_ciou(self): | 330 | def test_wrapper_npu_ciou(self): |
| 322 | class Model(torch.nn.Module): | 331 | class Model(torch.nn.Module): |
| 323 | def __init__(self): | 332 | def __init__(self): |
| @@ -338,6 +347,7 @@ class TestOnnxOps(TestCase): | |||
| 338 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 347 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 339 | onnx_model_name))) | 348 | onnx_model_name))) |
| 340 | 349 | ||
| 350 | + | ||
| 341 | def test_wrapper_npu_giou(self): | 351 | def test_wrapper_npu_giou(self): |
| 342 | class Model(torch.nn.Module): | 352 | class Model(torch.nn.Module): |
| 343 | def __init__(self): | 353 | def __init__(self): |
| @@ -364,6 +374,7 @@ class TestOnnxOps(TestCase): | |||
| 364 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 374 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 365 | onnx_model_name))) | 375 | onnx_model_name))) |
| 366 | 376 | ||
| 377 | + | ||
| 367 | def test_wrapper_npu_deformable_conv2d(self): | 378 | def test_wrapper_npu_deformable_conv2d(self): |
| 368 | class Model(torch.nn.Module): | 379 | class Model(torch.nn.Module): |
| 369 | def __init__(self): | 380 | def __init__(self): |
| @@ -386,6 +397,7 @@ class TestOnnxOps(TestCase): | |||
| 386 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 397 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 387 | onnx_model_name))) | 398 | onnx_model_name))) |
| 388 | 399 | ||
| 400 | + | ||
| 389 | def test_wrapper_npu_format_cast(self): | 401 | def test_wrapper_npu_format_cast(self): |
| 390 | class Model(torch.nn.Module): | 402 | class Model(torch.nn.Module): |
| 391 | def __init__(self): | 403 | def __init__(self): |
| @@ -405,6 +417,7 @@ class TestOnnxOps(TestCase): | |||
| 405 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 417 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 406 | onnx_model_name))) | 418 | onnx_model_name))) |
| 407 | 419 | ||
| 420 | + | ||
| 408 | def test_wrapper_npu_softmax_cross_entropy_with_logits(self): | 421 | def test_wrapper_npu_softmax_cross_entropy_with_logits(self): |
| 409 | class Model(torch.nn.Module): | 422 | class Model(torch.nn.Module): |
| 410 | def __init__(self): | 423 | def __init__(self): |
| @@ -425,6 +438,7 @@ class TestOnnxOps(TestCase): | |||
| 425 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 438 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 426 | onnx_model_name))) | 439 | onnx_model_name))) |
| 427 | 440 | ||
| 441 | + | ||
| 428 | def test_wrapper_npu_ps_roi_pooling(self): | 442 | def test_wrapper_npu_ps_roi_pooling(self): |
| 429 | class Model(torch.nn.Module): | 443 | class Model(torch.nn.Module): |
| 430 | def __init__(self): | 444 | def __init__(self): |
| @@ -452,6 +466,7 @@ class TestOnnxOps(TestCase): | |||
| 452 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 466 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 453 | onnx_model_name))) | 467 | onnx_model_name))) |
| 454 | 468 | ||
| 469 | + | ||
| 455 | def test_wrapper_npu_grid_assign_positive(self): | 470 | def test_wrapper_npu_grid_assign_positive(self): |
| 456 | class Model(torch.nn.Module): | 471 | class Model(torch.nn.Module): |
| 457 | def __init__(self): | 472 | def __init__(self): |
| @@ -512,6 +527,7 @@ class TestOnnxOps(TestCase): | |||
| 512 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 527 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 513 | onnx_model_name))) | 528 | onnx_model_name))) |
| 514 | 529 | ||
| 530 | + | ||
| 515 | def test_wrapper_npu_sign_bits_unpack(self): | 531 | def test_wrapper_npu_sign_bits_unpack(self): |
| 516 | class Model(torch.nn.Module): | 532 | class Model(torch.nn.Module): |
| 517 | def __init__(self): | 533 | def __init__(self): |
| @@ -533,6 +549,7 @@ class TestOnnxOps(TestCase): | |||
| 533 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 549 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 534 | onnx_model_name))) | 550 | onnx_model_name))) |
| 535 | 551 | ||
| 552 | + | ||
| 536 | def test_wrapper_npu_ptiou(self): | 553 | def test_wrapper_npu_ptiou(self): |
| 537 | class Model(torch.nn.Module): | 554 | class Model(torch.nn.Module): |
| 538 | def __init__(self): | 555 | def __init__(self): |
| @@ -559,6 +576,7 @@ class TestOnnxOps(TestCase): | |||
| 559 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 576 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 560 | onnx_model_name))) | 577 | onnx_model_name))) |
| 561 | 578 | ||
| 579 | + | ||
| 562 | def test_wrapper_npu_normalize_batch(self): | 580 | def test_wrapper_npu_normalize_batch(self): |
| 563 | class Model(torch.nn.Module): | 581 | class Model(torch.nn.Module): |
| 564 | def __init__(self): | 582 | def __init__(self): |
| @@ -580,6 +598,7 @@ class TestOnnxOps(TestCase): | |||
| 580 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 598 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 581 | onnx_model_name))) | 599 | onnx_model_name))) |
| 582 | 600 | ||
| 601 | + | ||
| 583 | def test_wrapper_npu_nms_v4(self): | 602 | def test_wrapper_npu_nms_v4(self): |
| 584 | class Model(torch.nn.Module): | 603 | class Model(torch.nn.Module): |
| 585 | def __init__(self): | 604 | def __init__(self): |
| @@ -606,6 +625,7 @@ class TestOnnxOps(TestCase): | |||
| 606 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 625 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 607 | onnx_model_name))) | 626 | onnx_model_name))) |
| 608 | 627 | ||
| 628 | + | ||
| 609 | def test_wrapper_npu_bounding_box_decode(self): | 629 | def test_wrapper_npu_bounding_box_decode(self): |
| 610 | class Model(torch.nn.Module): | 630 | class Model(torch.nn.Module): |
| 611 | def __init__(self): | 631 | def __init__(self): |
| @@ -628,6 +648,7 @@ class TestOnnxOps(TestCase): | |||
| 628 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 648 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 629 | onnx_model_name))) | 649 | onnx_model_name))) |
| 630 | 650 | ||
| 651 | + | ||
| 631 | def test_wrapper_npu_bounding_box_encode(self): | 652 | def test_wrapper_npu_bounding_box_encode(self): |
| 632 | class Model(torch.nn.Module): | 653 | class Model(torch.nn.Module): |
| 633 | def __init__(self): | 654 | def __init__(self): |
| @@ -650,6 +671,7 @@ class TestOnnxOps(TestCase): | |||
| 650 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 671 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 651 | onnx_model_name))) | 672 | onnx_model_name))) |
| 652 | 673 | ||
| 674 | + | ||
| 653 | def test_wrapper_npu_nms_with_mask(self): | 675 | def test_wrapper_npu_nms_with_mask(self): |
| 654 | class Model(torch.nn.Module): | 676 | class Model(torch.nn.Module): |
| 655 | def __init__(self): | 677 | def __init__(self): |
| @@ -672,6 +694,7 @@ class TestOnnxOps(TestCase): | |||
| 672 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 694 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 673 | onnx_model_name))) | 695 | onnx_model_name))) |
| 674 | 696 | ||
| 697 | + | ||
| 675 | def test_wrapper_npu_rotated_iou(self): | 698 | def test_wrapper_npu_rotated_iou(self): |
| 676 | class Model(torch.nn.Module): | 699 | class Model(torch.nn.Module): |
| 677 | def __init__(self): | 700 | def __init__(self): |
| @@ -702,6 +725,7 @@ class TestOnnxOps(TestCase): | |||
| 702 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 725 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 703 | onnx_model_name))) | 726 | onnx_model_name))) |
| 704 | 727 | ||
| 728 | + | ||
| 705 | def test_wrapper_npu_rotated_overlaps(self): | 729 | def test_wrapper_npu_rotated_overlaps(self): |
| 706 | class Model(torch.nn.Module): | 730 | class Model(torch.nn.Module): |
| 707 | def __init__(self): | 731 | def __init__(self): |
| @@ -731,6 +755,7 @@ class TestOnnxOps(TestCase): | |||
| 731 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 755 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 732 | onnx_model_name))) | 756 | onnx_model_name))) |
| 733 | 757 | ||
| 758 | + | ||
| 734 | def test_wrapper_npu_rotated_box_decode(self): | 759 | def test_wrapper_npu_rotated_box_decode(self): |
| 735 | class Model(torch.nn.Module): | 760 | class Model(torch.nn.Module): |
| 736 | def __init__(self): | 761 | def __init__(self): |
| @@ -755,6 +780,7 @@ class TestOnnxOps(TestCase): | |||
| 755 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 780 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 756 | onnx_model_name))) | 781 | onnx_model_name))) |
| 757 | 782 | ||
| 783 | + | ||
| 758 | def test_wrapper_npu_rotated_box_encode(self): | 784 | def test_wrapper_npu_rotated_box_encode(self): |
| 759 | class Model(torch.nn.Module): | 785 | class Model(torch.nn.Module): |
| 760 | def __init__(self): | 786 | def __init__(self): |
| @@ -779,6 +805,7 @@ class TestOnnxOps(TestCase): | |||
| 779 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 805 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 780 | onnx_model_name))) | 806 | onnx_model_name))) |
| 781 | 807 | ||
| 808 | + | ||
| 782 | def test_wrapper_npu_yolo_boxes_encode(self): | 809 | def test_wrapper_npu_yolo_boxes_encode(self): |
| 783 | class Model(torch.nn.Module): | 810 | class Model(torch.nn.Module): |
| 784 | def __init__(self): | 811 | def __init__(self): |
| @@ -801,6 +828,7 @@ class TestOnnxOps(TestCase): | |||
| 801 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 828 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 802 | onnx_model_name))) | 829 | onnx_model_name))) |
| 803 | 830 | ||
| 831 | + | ||
| 804 | def test_wrapper_npu_masked_fill_range(self): | 832 | def test_wrapper_npu_masked_fill_range(self): |
| 805 | class Model(torch.nn.Module): | 833 | class Model(torch.nn.Module): |
| 806 | def __init__(self): | 834 | def __init__(self): |
| @@ -824,6 +852,7 @@ class TestOnnxOps(TestCase): | |||
| 824 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 852 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 825 | onnx_model_name))) | 853 | onnx_model_name))) |
| 826 | 854 | ||
| 855 | + | ||
| 827 | def test_wrapper_npu_anchor_response_flags(self): | 856 | def test_wrapper_npu_anchor_response_flags(self): |
| 828 | class Model(torch.nn.Module): | 857 | class Model(torch.nn.Module): |
| 829 | def __init__(self): | 858 | def __init__(self): |
| @@ -843,6 +872,7 @@ class TestOnnxOps(TestCase): | |||
| 843 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 872 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 844 | onnx_model_name))) | 873 | onnx_model_name))) |
| 845 | 874 | ||
| 875 | + | ||
| 846 | def test_wrapper_npu_indexing(self): | 876 | def test_wrapper_npu_indexing(self): |
| 847 | class Model(torch.nn.Module): | 877 | class Model(torch.nn.Module): |
| 848 | def __init__(self): | 878 | def __init__(self): |
| @@ -863,6 +893,7 @@ class TestOnnxOps(TestCase): | |||
| 863 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 893 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 864 | onnx_model_name))) | 894 | onnx_model_name))) |
| 865 | 895 | ||
| 896 | + | ||
| 866 | def test_wrapper_npu_sign_bits_pack(self): | 897 | def test_wrapper_npu_sign_bits_pack(self): |
| 867 | class Model(torch.nn.Module): | 898 | class Model(torch.nn.Module): |
| 868 | def __init__(self): | 899 | def __init__(self): |
| @@ -884,6 +915,7 @@ class TestOnnxOps(TestCase): | |||
| 884 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 915 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 885 | onnx_model_name))) | 916 | onnx_model_name))) |
| 886 | 917 | ||
| 918 | + | ||
| 887 | def test_wrapper_npu_stride_add(self): | 919 | def test_wrapper_npu_stride_add(self): |
| 888 | class Model(torch.nn.Module): | 920 | class Model(torch.nn.Module): |
| 889 | def __init__(self): | 921 | def __init__(self): |
| @@ -905,6 +937,7 @@ class TestOnnxOps(TestCase): | |||
| 905 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 937 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 906 | onnx_model_name))) | 938 | onnx_model_name))) |
| 907 | 939 | ||
| 940 | + | ||
| 908 | def test_wrapper_npu_lstm_cell(self): | 941 | def test_wrapper_npu_lstm_cell(self): |
| 909 | class Model(torch.nn.Module): | 942 | class Model(torch.nn.Module): |
| 910 | def __init__(self): | 943 | def __init__(self): |
| @@ -956,6 +989,7 @@ class TestOnnxOps(TestCase): | |||
| 956 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 989 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 957 | onnx_model_name))) | 990 | onnx_model_name))) |
| 958 | 991 | ||
| 992 | + | ||
| 959 | def test_wrapper_npu_lstm(self): | 993 | def test_wrapper_npu_lstm(self): |
| 960 | class Model(torch.nn.Module): | 994 | class Model(torch.nn.Module): |
| 961 | def __init__(self): | 995 | def __init__(self): |
| @@ -1012,6 +1046,7 @@ class TestOnnxOps(TestCase): | |||
| 1012 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1046 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1013 | onnx_model_name))) | 1047 | onnx_model_name))) |
| 1014 | 1048 | ||
| 1049 | + | ||
| 1015 | def test_wrapper_npu_gru(self): | 1050 | def test_wrapper_npu_gru(self): |
| 1016 | class Model(torch.nn.Module): | 1051 | class Model(torch.nn.Module): |
| 1017 | def __init__(self): | 1052 | def __init__(self): |
| @@ -1061,7 +1096,8 @@ class TestOnnxOps(TestCase): | |||
| 1061 | export_onnx(onnx_model_name) | 1096 | export_onnx(onnx_model_name) |
| 1062 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1097 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1063 | onnx_model_name))) | 1098 | onnx_model_name))) |
| 1064 | - | 1099 | + |
| 1100 | + | ||
| 1065 | def test_wrapper_npu_dropout_with_add_softmax(self): | 1101 | def test_wrapper_npu_dropout_with_add_softmax(self): |
| 1066 | class Model(torch.nn.Module): | 1102 | class Model(torch.nn.Module): |
| 1067 | def __init__(self): | 1103 | def __init__(self): |
| @@ -1086,6 +1122,7 @@ class TestOnnxOps(TestCase): | |||
| 1086 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1122 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1087 | onnx_model_name))) | 1123 | onnx_model_name))) |
| 1088 | 1124 | ||
| 1125 | + | ||
| 1089 | def test_wrapper_npu_scaled_masked_softmax(self): | 1126 | def test_wrapper_npu_scaled_masked_softmax(self): |
| 1090 | class Model(torch.nn.Module): | 1127 | class Model(torch.nn.Module): |
| 1091 | def __init__(self): | 1128 | def __init__(self): |
| @@ -1108,7 +1145,8 @@ class TestOnnxOps(TestCase): | |||
| 1108 | export_onnx(onnx_model_name) | 1145 | export_onnx(onnx_model_name) |
| 1109 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1146 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1110 | onnx_model_name))) | 1147 | onnx_model_name))) |
| 1111 | - | 1148 | + |
| 1149 | + | ||
| 1112 | 1150 | ||
| 1113 | def test_wrapper_npu_moe_compute_expert_tokens(self): | 1151 | def test_wrapper_npu_moe_compute_expert_tokens(self): |
| 1114 | class Model(torch.nn.Module): | 1152 | class Model(torch.nn.Module): |
| @@ -1130,6 +1168,7 @@ class TestOnnxOps(TestCase): | |||
| 1130 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1168 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1131 | onnx_model_name))) | 1169 | onnx_model_name))) |
| 1132 | 1170 | ||
| 1171 | + | ||
| 1133 | def test_wrapper_npu_mish(self): | 1172 | def test_wrapper_npu_mish(self): |
| 1134 | class Model(torch.nn.Module): | 1173 | class Model(torch.nn.Module): |
| 1135 | def __init__(self): | 1174 | def __init__(self): |
| @@ -1149,6 +1188,7 @@ class TestOnnxOps(TestCase): | |||
| 1149 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1188 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1150 | onnx_model_name))) | 1189 | onnx_model_name))) |
| 1151 | 1190 | ||
| 1191 | + | ||
| 1152 | 1192 | ||
| 1153 | def test_wrapper_npu_deep_norm(self): | 1193 | def test_wrapper_npu_deep_norm(self): |
| 1154 | class Model(torch.nn.Module): | 1194 | class Model(torch.nn.Module): |
| @@ -1174,6 +1214,7 @@ class TestOnnxOps(TestCase): | |||
| 1174 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1214 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1175 | onnx_model_name))) | 1215 | onnx_model_name))) |
| 1176 | 1216 | ||
| 1217 | + | ||
| 1177 | 1218 | ||
| 1178 | def test_wrapper_npu_rms_norm(self): | 1219 | def test_wrapper_npu_rms_norm(self): |
| 1179 | class Model(torch.nn.Module): | 1220 | class Model(torch.nn.Module): |
| @@ -1196,6 +1237,7 @@ class TestOnnxOps(TestCase): | |||
| 1196 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1237 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1197 | onnx_model_name))) | 1238 | onnx_model_name))) |
| 1198 | 1239 | ||
| 1240 | + | ||
| 1199 | 1241 | ||
| 1200 | def test_wrapper_npu_add_rms_norm(self): | 1242 | def test_wrapper_npu_add_rms_norm(self): |
| 1201 | class Model(torch.nn.Module): | 1243 | class Model(torch.nn.Module): |
| @@ -1219,6 +1261,7 @@ class TestOnnxOps(TestCase): | |||
| 1219 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1261 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1220 | onnx_model_name))) | 1262 | onnx_model_name))) |
| 1221 | 1263 | ||
| 1264 | + | ||
| 1222 | 1265 | ||
| 1223 | def test_wrapper_npu_rotary_mul(self): | 1266 | def test_wrapper_npu_rotary_mul(self): |
| 1224 | class Model(torch.nn.Module): | 1267 | class Model(torch.nn.Module): |
| @@ -1240,6 +1283,7 @@ class TestOnnxOps(TestCase): | |||
| 1240 | export_onnx(onnx_model_name) | 1283 | export_onnx(onnx_model_name) |
| 1241 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1284 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1242 | 1285 | ||
| 1286 | + | ||
| 1243 | 1287 | ||
| 1244 | def test_wrapper_npu_masked_softmax_with_rel_pos_bias(self): | 1288 | def test_wrapper_npu_masked_softmax_with_rel_pos_bias(self): |
| 1245 | class Model(torch.nn.Module): | 1289 | class Model(torch.nn.Module): |
| @@ -1263,6 +1307,7 @@ class TestOnnxOps(TestCase): | |||
| 1263 | export_onnx(onnx_model_name) | 1307 | export_onnx(onnx_model_name) |
| 1264 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1308 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1265 | 1309 | ||
| 1310 | + | ||
| 1266 | 1311 | ||
| 1267 | def test_wrapper_npu_dynamic_quant(self): | 1312 | def test_wrapper_npu_dynamic_quant(self): |
| 1268 | class Model(torch.nn.Module): | 1313 | class Model(torch.nn.Module): |
| @@ -1284,6 +1329,7 @@ class TestOnnxOps(TestCase): | |||
| 1284 | export_onnx(onnx_model_name) | 1329 | export_onnx(onnx_model_name) |
| 1285 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1330 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1286 | 1331 | ||
| 1332 | + | ||
| 1287 | 1333 | ||
| 1288 | def test_wrapper_npu_dynamic_quant_with_group_index(self): | 1334 | def test_wrapper_npu_dynamic_quant_with_group_index(self): |
| 1289 | class Model(torch.nn.Module): | 1335 | class Model(torch.nn.Module): |
| @@ -1312,7 +1358,8 @@ class TestOnnxOps(TestCase): | |||
| 1312 | onnx_model_name = "model_npu_dynamic_quant.onnx" | 1358 | onnx_model_name = "model_npu_dynamic_quant.onnx" |
| 1313 | export_onnx(onnx_model_name) | 1359 | export_onnx(onnx_model_name) |
| 1314 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1360 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1315 | - | 1361 | + |
| 1362 | + | ||
| 1316 | 1363 | ||
| 1317 | def test_wrapper_npu_dynamic_quant_asymmetric(self): | 1364 | def test_wrapper_npu_dynamic_quant_asymmetric(self): |
| 1318 | class Model(torch.nn.Module): | 1365 | class Model(torch.nn.Module): |
| @@ -1342,6 +1389,7 @@ class TestOnnxOps(TestCase): | |||
| 1342 | export_onnx(onnx_model_name) | 1389 | export_onnx(onnx_model_name) |
| 1343 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1390 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1344 | 1391 | ||
| 1392 | + | ||
| 1345 | 1393 | ||
| 1346 | def test_wrapper_npu_weight_quant_batchmatmul(self): | 1394 | def test_wrapper_npu_weight_quant_batchmatmul(self): |
| 1347 | class Model(torch.nn.Module): | 1395 | class Model(torch.nn.Module): |
| @@ -1364,6 +1412,7 @@ class TestOnnxOps(TestCase): | |||
| 1364 | export_onnx(onnx_model_name) | 1412 | export_onnx(onnx_model_name) |
| 1365 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1413 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1366 | 1414 | ||
| 1415 | + | ||
| 1367 | 1416 | ||
| 1368 | def test_wrapper_npu_anti_quant(self): | 1417 | def test_wrapper_npu_anti_quant(self): |
| 1369 | class Model(torch.nn.Module): | 1418 | class Model(torch.nn.Module): |
| @@ -1385,6 +1434,7 @@ class TestOnnxOps(TestCase): | |||
| 1385 | export_onnx(onnx_model_name) | 1434 | export_onnx(onnx_model_name) |
| 1386 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) | 1435 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, onnx_model_name))) |
| 1387 | 1436 | ||
| 1437 | + | ||
| 1388 | def test_wrapper_npu_quantize(self): | 1438 | def test_wrapper_npu_quantize(self): |
| 1389 | class Model(torch.nn.Module): | 1439 | class Model(torch.nn.Module): |
| 1390 | def __init__(self): | 1440 | def __init__(self): |
| @@ -1408,6 +1458,7 @@ class TestOnnxOps(TestCase): | |||
| 1408 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1458 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1409 | onnx_model_name))) | 1459 | onnx_model_name))) |
| 1410 | 1460 | ||
| 1461 | + | ||
| 1411 | 1462 | ||
| 1412 | def test_wrapper_npu_group_quant(self): | 1463 | def test_wrapper_npu_group_quant(self): |
| 1413 | class Model(torch.nn.Module): | 1464 | class Model(torch.nn.Module): |
| @@ -1434,6 +1485,7 @@ class TestOnnxOps(TestCase): | |||
| 1434 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1485 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1435 | onnx_model_name))) | 1486 | onnx_model_name))) |
| 1436 | 1487 | ||
| 1488 | + | ||
| 1437 | 1489 | ||
| 1438 | def test_wrapper_npu_moe_finalize_routing(self): | 1490 | def test_wrapper_npu_moe_finalize_routing(self): |
| 1439 | class Model(torch.nn.Module): | 1491 | class Model(torch.nn.Module): |
| @@ -1466,6 +1518,7 @@ class TestOnnxOps(TestCase): | |||
| 1466 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1518 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1467 | onnx_model_name))) | 1519 | onnx_model_name))) |
| 1468 | 1520 | ||
| 1521 | + | ||
| 1469 | 1522 | ||
| 1470 | def test_wrapper_npu_moe_finalize_routing_v2(self): | 1523 | def test_wrapper_npu_moe_finalize_routing_v2(self): |
| 1471 | class Model(torch.nn.Module): | 1524 | class Model(torch.nn.Module): |
| @@ -1500,6 +1553,7 @@ class TestOnnxOps(TestCase): | |||
| 1500 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, | 1553 | assert (os.path.isfile(os.path.join(TestOnnxOps.test_onnx_path, |
| 1501 | onnx_model_name))) | 1554 | onnx_model_name))) |
| 1502 | 1555 | ||
| 1556 | + | ||
| 1503 | 1557 | ||
| 1504 | def test_wrapper_npu_gelu(self): | 1558 | def test_wrapper_npu_gelu(self): |
| 1505 | class Model(torch.nn.Module): | 1559 | class Model(torch.nn.Module): |
| @@ -2157,7 +2157,7 @@ | |||
| 2157 | "signature": "(self, rois, spatial_scale, pooled_height, pooled_width, sample_num, roi_end_mode)" | 2157 | "signature": "(self, rois, spatial_scale, pooled_height, pooled_width, sample_num, roi_end_mode)" |
| 2158 | }, | 2158 | }, |
| 2159 | "torch_npu.npu_rotary_mul": { | 2159 | "torch_npu.npu_rotary_mul": { |
| 2160 | - "signature": "(x, r1, r2)" | 2160 | + "signature": "(input, r1, r2, rotary_mode='half')" |
| 2161 | }, | 2161 | }, |
| 2162 | "torch_npu.npu_rotated_iou": { | 2162 | "torch_npu.npu_rotated_iou": { |
| 2163 | "signature": "(self, query_boxes, trans=False, mode=0, is_cross=True, v_threshold=0.0, e_threshold=0.0)" | 2163 | "signature": "(self, query_boxes, trans=False, mode=0, is_cross=True, v_threshold=0.0, e_threshold=0.0)" |
| @@ -2226,7 +2226,7 @@ | |||
| 2226 | "signature": "(sorted_experts, num_experts=1)" | 2226 | "signature": "(sorted_experts, num_experts=1)" |
| 2227 | }, | 2227 | }, |
| 2228 | "torch_npu.npu_group_norm_silu": { | 2228 | "torch_npu.npu_group_norm_silu": { |
| 2229 | - "signature": "(x, gamma, beta, group, eps=1e-05)" | 2229 | + "signature": "(input, weight, bias, group, eps=1e-05)" |
| 2230 | }, | 2230 | }, |
| 2231 | "torch_npu.npu_gelu": { | 2231 | "torch_npu.npu_gelu": { |
| 2232 | "signature": "(x, approximate='none')" | 2232 | "signature": "(x, approximate='none')" |
| @@ -27669,6 +27669,61 @@ | |||
| 27669 | "test_resnet (test_models.TestModels_new_jit_API)": ["", [""]], | 27669 | "test_resnet (test_models.TestModels_new_jit_API)": ["", [""]], |
| 27670 | "test_mc3_18_video (test_models.TestModels_new_jit_API)": ["", [""]], | 27670 | "test_mc3_18_video (test_models.TestModels_new_jit_API)": ["", [""]], |
| 27671 | "test_mobilenet (__main__.TestModels)": ["", [""]], | 27671 | "test_mobilenet (__main__.TestModels)": ["", [""]], |
| 27672 | + "test_mobilenet_v3 (__main__.TestQuantizedModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 27673 | + "test_resnet18 (__main__.TestQuantizedModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 27674 | + "test_resnet50 (__main__.TestQuantizedModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 27675 | + "test_resnext101_32x8d (__main__.TestQuantizedModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 27676 | + "test_mobilenet_v3 (__main__.TestQuantizedModelsONNXRuntime_is_script_True)": ["", [""]], | ||
| 27677 | + "test_resnet18 (__main__.TestQuantizedModelsONNXRuntime_is_script_True)": ["", [""]], | ||
| 27678 | + "test_resnet50 (__main__.TestQuantizedModelsONNXRuntime_is_script_True)": ["", [""]], | ||
| 27679 | + "test_resnext101_32x8d (__main__.TestQuantizedModelsONNXRuntime_is_script_True)": ["", [""]], | ||
| 27680 | + "test_verbose (__main__.TestUtilityFuns_opset_9)": ["", [""]], | ||
| 27681 | + "test_verbose (__main__.TestUtilityFuns_opset_10)": ["", [""]], | ||
| 27682 | + "test_verbose (__main__.TestUtilityFuns_opset_11)": ["", [""]], | ||
| 27683 | + "test_verbose (__main__.TestUtilityFuns_opset_12)": ["", [""]], | ||
| 27684 | + "test_verbose (__main__.TestUtilityFuns_opset_13)": ["", [""]], | ||
| 27685 | + "test_verbose (__main__.TestUtilityFuns_opset_14)": ["", [""]], | ||
| 27686 | + "test_verbose (__main__.TestUtilityFuns_opset_15)": ["", [""]], | ||
| 27687 | + "test_verbose (__main__.TestUtilityFuns_opset_16)": ["", [""]], | ||
| 27688 | + "test_verbose (__main__.TestUtilityFuns_opset_17)": ["", [""]], | ||
| 27689 | + "test_verbose (__main__.TestUtilityFuns_opset_18)": ["", [""]], | ||
| 27690 | + "test_verbose (__main__.TestUtilityFuns_opset_19)": ["", [""]], | ||
| 27691 | + "test_verbose (__main__.TestUtilityFuns_opset_20)": ["", [""]], | ||
| 27692 | + "test_api_compatibility (__main__.TestPublicApiCompatibility)": ["", [""]], | ||
| 27693 | + "test_wrapper_npu_fused_attention_layernorm_qkv_fwd (__main__.TestOnnxOps)": ["", [""]], | ||
| 27694 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27695 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27696 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27697 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_13_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27698 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27699 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27700 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27701 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_14_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27702 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27703 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27704 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27705 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_15_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27706 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27707 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27708 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27709 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_16_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27710 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27711 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27712 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27713 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_17_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27714 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27715 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27716 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27717 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_18_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27718 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27719 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27720 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27721 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_19_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27722 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27723 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_False_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27724 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_False)": ["", [""]], | ||
| 27725 | + "test_arithmetic_bfp16 (__main__.TestONNXRuntime_npu_opset_version_20_is_script_True_keep_initializers_as_inputs_True)": ["", [""]], | ||
| 27726 | + "test_faster_rcnn (__main__.TestModelsONNXRuntime_is_script_False)": ["", [""]], | ||
| 27672 | "test_shufflenet (__main__.TestModels)": ["", [""]], | 27727 | "test_shufflenet (__main__.TestModels)": ["", [""]], |
| 27673 | "test_r2plus1d_18_video (__main__.TestModels)": ["", [""]], | 27728 | "test_r2plus1d_18_video (__main__.TestModels)": ["", [""]], |
| 27674 | "test_mc3_18_video (test_models.TestModels)": ["", [""]], | 27729 | "test_mc3_18_video (test_models.TestModels)": ["", [""]], |
| @@ -137,10 +137,17 @@ class _NPUGroupNormSiluOP(torch.autograd.Function): | |||
| 137 | 137 | ||
| 138 | def symbolic(g, self: Tensor, gamma: Optional[Tensor], beta: Optional[Tensor], | 138 | def symbolic(g, self: Tensor, gamma: Optional[Tensor], beta: Optional[Tensor], |
| 139 | group: int, eps: float = 0.00001): | 139 | group: int, eps: float = 0.00001): |
| 140 | + self_sizes = self.type().sizes() | ||
| 141 | + self_dims = len(self_sizes) | ||
| 142 | + if (self_dims < 2): | ||
| 143 | + raise ValueError("self dim must be larger than 2, but got ", self_dims, pta_error(ErrCode.VALUE)) | ||
| 144 | + | ||
| 145 | + shape_c = self_sizes[1] | ||
| 146 | + self_dtype = self.type().dtype() | ||
| 140 | if gamma is None: | 147 | if gamma is None: |
| 141 | - gamma = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 148 | + gamma = g.op("Constant", value_t=torch.ones([shape_c], dtype=self_dtype)) |
| 142 | if beta is None: | 149 | if beta is None: |
| 143 | - beta = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 150 | + beta = g.op("Constant", value_t=torch.zeros([shape_c], dtype=self_dtype)) |
| 144 | return g.op("npu::NPUGroupNormSilu", self, gamma, beta, group_i=group, eps_f=eps, | 151 | return g.op("npu::NPUGroupNormSilu", self, gamma, beta, group_i=group, eps_f=eps, |
| 145 | outputs=3) | 152 | outputs=3) |
| 146 | 153 | ||
| @@ -660,8 +667,8 @@ class _NPURotaryMulOP(torch.autograd.Function): | |||
| 660 | return torch.ops.npu.npu_rotary_mul(*args, **kwargs) | 667 | return torch.ops.npu.npu_rotary_mul(*args, **kwargs) |
| 661 | 668 | ||
| 662 | 669 | ||
| 663 | - def symbolic(g, x: Tensor, r1: Tensor, r2: Tensor): | 670 | + def symbolic(g, x: Tensor, r1: Tensor, r2: Tensor, rotary_mode: str = "half"): |
| 664 | - return g.op("npu::NPURotaryMul", x, r1, r2) | 671 | + return g.op("npu::NPURotaryMul", x, r1, r2, rotary_mode_s=rotary_mode) |
| 665 | 672 | ||
| 666 | 673 | ||
| 667 | class _NPUPromptFlashAttentionOP(torch.autograd.Function): | 674 | class _NPUPromptFlashAttentionOP(torch.autograd.Function): |
| @@ -935,16 +942,32 @@ class _NPUMoeFinalizeRoutingV2OP(torch.autograd.Function): | |||
| 935 | skip2: Optional[Tensor], bias: Optional[Tensor], | 942 | skip2: Optional[Tensor], bias: Optional[Tensor], |
| 936 | scales: Optional[Tensor], expanded_src_to_dst_row: Tensor, | 943 | scales: Optional[Tensor], expanded_src_to_dst_row: Tensor, |
| 937 | export_for_source_row: Optional[Tensor], drop_pad_mode: int = 0): | 944 | export_for_source_row: Optional[Tensor], drop_pad_mode: int = 0): |
| 945 | + expanded_permuted_rows_sizes = expanded_permuted_rows.type().sizes() | ||
| 946 | + expanded_permuted_rows_dims = len(expanded_permuted_rows_sizes) | ||
| 947 | + if (expanded_permuted_rows_dims < 2): | ||
| 948 | + raise ValueError("expanded_permuted_rows dim must be larger than 2, but got ", expanded_permuted_rows_dims, | ||
| 949 | + pta_error(ErrCode.VALUE)) | ||
| 950 | + | ||
| 951 | + rows_k, h, k = expanded_permuted_rows_sizes[0], expanded_permuted_rows_sizes[1], 1 | ||
| 952 | + if scales is not None: | ||
| 953 | + scales_sizes = scales.type().sizes() | ||
| 954 | + scales_dims = len(scales_sizes) | ||
| 955 | + if (scales_dims < 2): | ||
| 956 | + raise ValueError("scales dim must be larger than 2, but got ", scales_dims, pta_error(ErrCode.VALUE)) | ||
| 957 | + k = scales_sizes[1] | ||
| 958 | + | ||
| 959 | + rows = rows_k // k | ||
| 960 | + expanded_permuted_rows_dtype = expanded_permuted_rows.type().dtype() | ||
| 938 | if skip1 is None: | 961 | if skip1 is None: |
| 939 | - skip1 = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 962 | + skip1 = g.op("Constant", value_t=torch.zeros([rows, h], dtype=expanded_permuted_rows_dtype)) |
| 940 | if skip2 is None: | 963 | if skip2 is None: |
| 941 | - skip2 = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 964 | + skip2 = g.op("Constant", value_t=torch.zeros([rows, h], dtype=expanded_permuted_rows_dtype)) |
| 942 | if bias is None: | 965 | if bias is None: |
| 943 | - bias = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 966 | + bias = g.op("Constant", value_t=torch.zeros([1, h], dtype=expanded_permuted_rows_dtype)) |
| 944 | if scales is None: | 967 | if scales is None: |
| 945 | - scales = g.op("Constant", value_t=torch.tensor([]).to(torch.float)) | 968 | + scales = g.op("Constant", value_t=torch.ones([rows, k], dtype=expanded_permuted_rows_dtype)) |
| 946 | if export_for_source_row is None: | 969 | if export_for_source_row is None: |
| 947 | - export_for_source_row = g.op("Constant", value_t=torch.tensor([]).to(torch.int32)) | 970 | + export_for_source_row = g.op("Constant", value_t=torch.zeros([rows, k], dtype=torch.int32)) |
| 948 | return g.op("npu::NPUMoeFinalizeRoutingV2", expanded_permuted_rows, expanded_src_to_dst_row, skip1, skip2, bias, | 971 | return g.op("npu::NPUMoeFinalizeRoutingV2", expanded_permuted_rows, expanded_src_to_dst_row, skip1, skip2, bias, |
| 949 | scales, export_for_source_row, drop_pad_mode_i=drop_pad_mode) | 972 | scales, export_for_source_row, drop_pad_mode_i=drop_pad_mode) |
| 950 | 973 | ||
| @@ -1066,8 +1089,8 @@ def _wrapper_npu_deep_norm(self, gx, beta, gamma, alpha=0.3, epsilon=1e-6): | |||
| 1066 | return _NPUDeepNormOP.apply(self, gx, beta, gamma, alpha, epsilon) | 1089 | return _NPUDeepNormOP.apply(self, gx, beta, gamma, alpha, epsilon) |
| 1067 | 1090 | ||
| 1068 | 1091 | ||
| 1069 | -def _wrapper_npu_group_norm_silu(x, gamma, beta, group, eps=0.00001): | 1092 | +def _wrapper_npu_group_norm_silu(input, weight, bias, group, eps=0.00001): |
| 1070 | - return _NPUGroupNormSiluOP.apply(x, gamma, beta, group, eps) | 1093 | + return _NPUGroupNormSiluOP.apply(input, weight, bias, group, eps) |
| 1071 | 1094 | ||
| 1072 | 1095 | ||
| 1073 | def _wrapper_npu_ifmr(data, data_min, data_max, cumsum, min_percentile, max_percentile, | 1096 | def _wrapper_npu_ifmr(data, data_min, data_max, cumsum, min_percentile, max_percentile, |
| @@ -1216,8 +1239,8 @@ def _wrapper_npu_mish(self): | |||
| 1216 | return _NPUMishOP.apply(self) | 1239 | return _NPUMishOP.apply(self) |
| 1217 | 1240 | ||
| 1218 | 1241 | ||
| 1219 | -def _wrapper_npu_rotary_mul(x, r1, r2): | 1242 | +def _wrapper_npu_rotary_mul(input, r1, r2, rotary_mode="half"): |
| 1220 | - return _NPURotaryMulOP.apply(x, r1, r2) | 1243 | + return _NPURotaryMulOP.apply(input, r1, r2, rotary_mode) |
| 1221 | 1244 | ||
| 1222 | 1245 | ||
| 1223 | def _wrapper_npu_prompt_flash_attention(self, query, key, value, padding_mask, atten_mask, pse_shift, actual_seq_lengths, | 1246 | def _wrapper_npu_prompt_flash_attention(self, query, key, value, padding_mask, atten_mask, pse_shift, actual_seq_lengths, |